[Ssh-sftp-perl-users] Timeout when executing scripts with Net::SSH::Perl by mod_perl
Brought to you by:
dbrobins
From: uptest <up...@ao...> - 2010-10-22 10:37:42
|
Dear all, I have a problem when executing scripts with Net::SSH::Perl by mod_perl. When executing the script via mod_perl the ssh connection will be opened, the $cmd executed but the output is never returned to the caller. It hangs until a timeout occur. Nothing will be sent to the web browser. If I execute the script locally it works fine. The sample script just opens a ssh connection to the localhost: my $ssh = Net::SSH::Perl->new($host,%params); $ssh->login($user, $pass); my($stdout, $stderr, $exit) = $ssh->cmd($cmd); print "STDOUT=$stdout\n"; print "STDERR=$stderr\n"; print "EXIT=$exit\n"; See below the debug output when executed first by mod_perl then by a local shell: Debug output when executed via mod_perl: from /var/log/httpd/error.log anyhost: Reading configuration data /.ssh/config anyhost: Reading configuration data /etc/ssh_config anyhost: Connecting to localhost, port 22. anyhost: Remote protocol version 2.0, remote software version OpenSSH_5.0 anyhost: Net::SSH::Perl Version 1.34, protocol version 2.0. anyhost: No compat match: OpenSSH_5.0. anyhost: Connection established. anyhost: Sent key-exchange init (KEXINIT), wait response. anyhost: Algorithms, c->s: 3des-cbc hmac-sha1 none anyhost: Algorithms, s->c: 3des-cbc hmac-sha1 none anyhost: Entering Diffie-Hellman Group 1 key exchange. anyhost: Sent DH public key, waiting for reply. anyhost: Received host key, type 'ssh-dss'. anyhost: Host 'localhost' is known and matches the host key. anyhost: Computing shared secret key. anyhost: Verifying server signature. anyhost: Waiting for NEWKEYS message. anyhost: Send NEWKEYS. anyhost: Enabling encryption/MAC/compression. anyhost: Sending request for user-authentication service. anyhost: Service accepted: ssh-userauth. anyhost: Trying empty user-authentication request. anyhost: Authentication methods that can continue: publickey,gssapi-with-mic,password. anyhost: Next method to try is publickey. anyhost: Next method to try is password. anyhost: Trying password authentication. anyhost: Login completed, opening dummy shell channel. anyhost: channel 0: new [client-session] anyhost: Requesting channel_open for channel 0. anyhost: channel 0: open confirm rwindow 0 rmax 32768 anyhost: Got channel open confirmation, requesting shell. anyhost: Requesting service shell on channel 0. anyhost: channel 1: new [client-session] anyhost: Requesting channel_open for channel 1. anyhost: Entering interactive session. anyhost: Sending command: ls -ltr anyhost: Sending command: ls -ltr anyhost: Requesting service exec on channel 1. anyhost: channel 1: open confirm rwindow 0 rmax 32768 anyhost: input_channel_request: rtype exit-status reply 0 anyhost: channel 1: rcvd eof anyhost: channel 1: output open -> drain anyhost: channel 1: rcvd close anyhost: channel 1: input open -> closed anyhost: channel 1: close_read ------------------------------------------------------------------ Started from the local shell: anyhost: Reading configuration data /root/.ssh/config anyhost: Reading configuration data /etc/ssh_config anyhost: Allocated local port 1023. anyhost: Connecting to localhost, port 22. anyhost: Remote protocol version 2.0, remote software version OpenSSH_5.0 anyhost: Net::SSH::Perl Version 1.34, protocol version 2.0. anyhost: No compat match: OpenSSH_5.0. anyhost: Connection established. anyhost: Sent key-exchange init (KEXINIT), wait response. anyhost: Algorithms, c->s: 3des-cbc hmac-sha1 none anyhost: Algorithms, s->c: 3des-cbc hmac-sha1 none anyhost: Entering Diffie-Hellman Group 1 key exchange. anyhost: Sent DH public key, waiting for reply. anyhost: Received host key, type 'ssh-dss'. anyhost: Host 'localhost' is known and matches the host key. anyhost: Computing shared secret key. anyhost: Verifying server signature. anyhost: Waiting for NEWKEYS message. anyhost: Send NEWKEYS. anyhost: Enabling encryption/MAC/compression. anyhost: Sending request for user-authentication service. anyhost: Service accepted: ssh-userauth. anyhost: Trying empty user-authentication request. anyhost: Authentication methods that can continue: publickey,gssapi-with-mic,password. anyhost: Next method to try is publickey. anyhost: Next method to try is password. anyhost: Trying password authentication. anyhost: Login completed, opening dummy shell channel. anyhost: channel 0: new [client-session] anyhost: Requesting channel_open for channel 0. anyhost: channel 0: open confirm rwindow 0 rmax 32768 anyhost: Got channel open confirmation, requesting shell. anyhost: Requesting service shell on channel 0. anyhost: channel 1: new [client-session] anyhost: Requesting channel_open for channel 1. anyhost: Entering interactive session. anyhost: Sending command: ls -ltr anyhost: Sending command: ls -ltr anyhost: Requesting service exec on channel 1. anyhost: channel 1: open confirm rwindow 0 rmax 32768 anyhost: input_channel_request: rtype exit-status reply 0 anyhost: channel 1: rcvd eof anyhost: channel 1: output open -> drain anyhost: channel 1: rcvd close anyhost: channel 1: input open -> closed anyhost: channel 1: close_read anyhost: channel 1: obuf empty anyhost: channel 1: output drain -> closed anyhost: channel 1: close_write anyhost: channel 1: send close anyhost: channel 1: full closed STDOUT=total 12156 -rw------- 1 root root 2022 Aug 13 2008 anaconda-ks.cfg drwxr-xr-x 2 root root 4096 Aug 14 2008 Desktop drwxr-xr-x 3 root root 4096 Sep 2 2008 workspace drwxr-xr-x 4 root root 4096 Oct 21 2008 SDC -rw-r--r-- 1 root root 1030 Feb 27 2009 connections.txt -rw-r--r-- 1 root root 86363 Aug 3 2009 SDABeans.jar -rw-r--r-- 1 root root 1687590 Aug 3 2009 SDAWeb.war -rw-r--r-- 1 root root 184 Nov 11 2009 TODO drwxr-xr-x 8 root root 4096 Nov 12 2009 backup -rw-r--r-- 1 root root 10416040 Nov 12 2009 OSSmigrate121109.gz -rw-r--r-- 1 root root 922 Nov 13 2009 svnAdmin.info drwxr-xr-x 4 root root 4096 May 11 17:14 tmp drwxr-xr-x 2 root root 4096 Jul 13 09:19 sh drwxr-xr-x 8 root root 4096 Aug 11 12:35 cpan drwxr-xr-x 7 root root 4096 Aug 11 13:05 BPM -rw------- 1 root root 139999 Aug 23 10:05 mbox drwxr-xr-x 7 root root 4096 Oct 14 14:42 Downloads Use of uninitialized value $stderr in concatenation (.) or string at ./local.pl line 20. STDERR= EXIT=0 END!!!!!!!! Thanks in advance for any help. Bye Uwe |