Thread: [Ssh-sftp-perl-users] Net::SSH::Perl cmd() hangs in mod_perl2
Brought to you by:
dbrobins
From: Kevin M. <kmc...@ba...> - 2008-12-20 20:19:46
|
Anyone using Net::SSH::Perl under mod_perl2? I can't seem to get cmd() to work within a mod_perl2 environment. I have the following code: my $ssh = Net::SSH::Perl->new($hostname); $ssh->login($user, $password); my($stdout, $stderr, $exit) = $ssh->cmd('ls'); Which works everywhere except if I'm in a mod_perl2 environment. If turn debugging on I get the following output at which point it hangs indefinitely: server1: Reading configuration data /.ssh/config server1: Reading configuration data /etc/ssh_config server1: Connecting to server2, port 22. server1: Remote protocol version 2.0, remote software version OpenSSH_3.9p1 server1: Net::SSH::Perl Version 1.33, protocol version 2.0. server1: No compat match: OpenSSH_3.9p1. server1: Connection established. server1: Sent key-exchange init (KEXINIT), wait response. server1: Algorithms, c->s: 3des-cbc hmac-sha1 none server1: Algorithms, s->c: 3des-cbc hmac-sha1 none server1: Entering Diffie-Hellman Group 1 key exchange. server1: Sent DH public key, waiting for reply. server1: Received host key, type 'ssh-dss'. server1: Host 'server2' is known and matches the host key. server1: Computing shared secret key. server1: Verifying server signature. server1: Waiting for NEWKEYS message. server1: Enabling incoming encryption/MAC/compression. server1: Send NEWKEYS, enable outgoing encryption/MAC/compression. server1: Sending request for user-authentication service. server1: Service accepted: ssh-userauth. server1: Trying empty user-authentication request. server1: Authentication methods that can continue: publickey,password. server1: Next method to try is publickey. server1: Trying pubkey authentication with key file '/var/www/.ssh/id_dsa' server1: Will not query passphrase for '/var/www/.ssh/id_dsa' in batch mode. server1: Loading private key failed. server1: Next method to try is password. server1: Trying password authentication. server1: Login completed, opening dummy shell channel. server1: channel 0: new [client-session] server1: Requesting channel_open for channel 0. server1: channel 0: open confirm rwindow 0 rmax 32768 server1: Got channel open confirmation, requesting shell. server1: Requesting service shell on channel 0. server1: channel 1: new [client-session] server1: Requesting channel_open for channel 1. server1: Entering interactive session. server1: Sending command: ls server1: Requesting service exec on channel 1. server1: channel 1: open confirm rwindow 0 rmax 32768 server1: input_channel_request: rtype exit-status reply 0 server1: channel 1: rcvd eof server1: channel 1: output open -> drain server1: channel 1: rcvd close server1: channel 1: input open -> closed server1: channel 1: close_read ----HANGS FOREVER---- |
From: David M. F. <mf...@tr...> - 2008-12-20 20:49:42
|
Try Net-SSH2 -----Original Message----- From: Kevin McGrath [mailto:kmc...@ba...] Sent: Saturday, December 20, 2008 1:27 PM To: ssh...@li... Subject: [Ssh-sftp-perl-users] Net::SSH::Perl cmd() hangs in mod_perl2 Anyone using Net::SSH::Perl under mod_perl2? I can't seem to get cmd() to work within a mod_perl2 environment. I have the following code: my $ssh = Net::SSH::Perl->new($hostname); $ssh->login($user, $password); my($stdout, $stderr, $exit) = $ssh->cmd('ls'); Which works everywhere except if I'm in a mod_perl2 environment. If turn debugging on I get the following output at which point it hangs indefinitely: server1: Reading configuration data /.ssh/config server1: Reading configuration data /etc/ssh_config server1: Connecting to server2, port 22. server1: Remote protocol version 2.0, remote software version OpenSSH_3.9p1 server1: Net::SSH::Perl Version 1.33, protocol version 2.0. server1: No compat match: OpenSSH_3.9p1. server1: Connection established. server1: Sent key-exchange init (KEXINIT), wait response. server1: Algorithms, c->s: 3des-cbc hmac-sha1 none server1: Algorithms, s->c: 3des-cbc hmac-sha1 none server1: Entering Diffie-Hellman Group 1 key exchange. server1: Sent DH public key, waiting for reply. server1: Received host key, type 'ssh-dss'. server1: Host 'server2' is known and matches the host key. server1: Computing shared secret key. server1: Verifying server signature. server1: Waiting for NEWKEYS message. server1: Enabling incoming encryption/MAC/compression. server1: Send NEWKEYS, enable outgoing encryption/MAC/compression. server1: Sending request for user-authentication service. server1: Service accepted: ssh-userauth. server1: Trying empty user-authentication request. server1: Authentication methods that can continue: publickey,password. server1: Next method to try is publickey. server1: Trying pubkey authentication with key file '/var/www/.ssh/id_dsa' server1: Will not query passphrase for '/var/www/.ssh/id_dsa' in batch mode. server1: Loading private key failed. server1: Next method to try is password. server1: Trying password authentication. server1: Login completed, opening dummy shell channel. server1: channel 0: new [client-session] server1: Requesting channel_open for channel 0. server1: channel 0: open confirm rwindow 0 rmax 32768 server1: Got channel open confirmation, requesting shell. server1: Requesting service shell on channel 0. server1: channel 1: new [client-session] server1: Requesting channel_open for channel 1. server1: Entering interactive session. server1: Sending command: ls server1: Requesting service exec on channel 1. server1: channel 1: open confirm rwindow 0 rmax 32768 server1: input_channel_request: rtype exit-status reply 0 server1: channel 1: rcvd eof server1: channel 1: output open -> drain server1: channel 1: rcvd close server1: channel 1: input open -> closed server1: channel 1: close_read ----HANGS FOREVER---- ---------------------------------------------------------------------------- -- _______________________________________________ Ssh-sftp-perl-users mailing list Ssh...@li... https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users |
From: Kevin M. <kmc...@ba...> - 2008-12-21 04:08:21
|
David M. Funk wrote: > Try Net-SSH2 > Thanks, it looks like Net::SSH2 does the trick. Took a bit to figure out that I needed to set blocking to 0. Kinda wish there was a more concise way to run a single command out of Net::SSH2 itself, but I guess I just wrap that up in my own module :) my $out = ''; if ($ssh2->auth_password($username,$password)) { my $chan = $ssh2->channel(); $chan->exec('ls'); $chan->blocking(0); while (my $line = <$chan>) { $out .= $line; } } print $out; > -----Original Message----- > From: Kevin McGrath [mailto:kmc...@ba...] > Sent: Saturday, December 20, 2008 1:27 PM > To: ssh...@li... > Subject: [Ssh-sftp-perl-users] Net::SSH::Perl cmd() hangs in mod_perl2 > > Anyone using Net::SSH::Perl under mod_perl2? I can't seem to get cmd() > to work within a mod_perl2 environment. I have the following code: > > my $ssh = Net::SSH::Perl->new($hostname); > $ssh->login($user, $password); > my($stdout, $stderr, $exit) = $ssh->cmd('ls'); > > Which works everywhere except if I'm in a mod_perl2 environment. If > turn debugging on I get the following output at which point it hangs > indefinitely: > > server1: Reading configuration data /.ssh/config > server1: Reading configuration data /etc/ssh_config > server1: Connecting to server2, port 22. > server1: Remote protocol version 2.0, remote software version OpenSSH_3.9p1 > server1: Net::SSH::Perl Version 1.33, protocol version 2.0. > server1: No compat match: OpenSSH_3.9p1. > server1: Connection established. > server1: Sent key-exchange init (KEXINIT), wait response. > server1: Algorithms, c->s: 3des-cbc hmac-sha1 none > server1: Algorithms, s->c: 3des-cbc hmac-sha1 none > server1: Entering Diffie-Hellman Group 1 key exchange. > server1: Sent DH public key, waiting for reply. > server1: Received host key, type 'ssh-dss'. > server1: Host 'server2' is known and matches the host key. > server1: Computing shared secret key. > server1: Verifying server signature. > server1: Waiting for NEWKEYS message. > server1: Enabling incoming encryption/MAC/compression. > server1: Send NEWKEYS, enable outgoing encryption/MAC/compression. > server1: Sending request for user-authentication service. > server1: Service accepted: ssh-userauth. > server1: Trying empty user-authentication request. > server1: Authentication methods that can continue: publickey,password. > server1: Next method to try is publickey. > server1: Trying pubkey authentication with key file '/var/www/.ssh/id_dsa' > server1: Will not query passphrase for '/var/www/.ssh/id_dsa' in batch mode. > server1: Loading private key failed. > server1: Next method to try is password. > server1: Trying password authentication. > server1: Login completed, opening dummy shell channel. > server1: channel 0: new [client-session] > server1: Requesting channel_open for channel 0. > server1: channel 0: open confirm rwindow 0 rmax 32768 > server1: Got channel open confirmation, requesting shell. > server1: Requesting service shell on channel 0. > server1: channel 1: new [client-session] > server1: Requesting channel_open for channel 1. > server1: Entering interactive session. > server1: Sending command: ls > server1: Requesting service exec on channel 1. > server1: channel 1: open confirm rwindow 0 rmax 32768 > server1: input_channel_request: rtype exit-status reply 0 > server1: channel 1: rcvd eof > server1: channel 1: output open -> drain > server1: channel 1: rcvd close > server1: channel 1: input open -> closed > server1: channel 1: close_read > > ----HANGS FOREVER---- > > > ---------------------------------------------------------------------------- > -- > _______________________________________________ > Ssh-sftp-perl-users mailing list > Ssh...@li... > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > > |