http://www.perlmonks.org?node_id=860858

dorko has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I'm trying to SSH from a Windows XP desktop to a Solaris box and run a command. I've installed Net::SSH::W32Perl on the Windows box. The script below seems to login correctly and send the command, but then it just hangs.

(For others researching this topic, the Web suggests commenting out lines 213 and 214 of Net:SSH::Perl.pm to get it working on Windows. If you install and use Net::SSH::W32Perl, it redefines the troublesome function in Net::SSH::Perl and you don't have to edit Net::SSH::Perl.)

I found this Re: Re: Re: Re: Re: SFTP hangs (winxp) and followed it's advise, but soulcage.net seems to be defunct.

Does anyone have any suggestions?

The script:

use strict; use warnings; use Net::SSH::W32Perl; $ENV{HOME} = 'C:\shaw\ssh'; my $host = 'super.cool.server'; my $ssh = Net::SSH::W32Perl->new($host, protocol => '2', debug => 1 ); my $user = 'supercooluser'; my $pass = 'supercoolpass'; $ssh->login($user, $pass); my $cmd = "pwd"; my($stdout, $stderr, $exit) = $ssh->cmd($cmd); print $stdout; print $stderr; print $exit;

The only results are the debug messages:

brentshaw: Reading configuration data C:\shaw\ssh/.ssh/config brentshaw: Reading configuration data /etc/ssh_config brentshaw: Connecting to xxx.xxx.xxx.xxx, port 22. brentshaw: Socket created, turning on blocking... brentshaw: Remote protocol version 2.0, remote software version Sun_SS +H_1.1.3 brentshaw: Net::SSH::Perl Version 1.34, protocol version 2.0. brentshaw: No compat match: Sun_SSH_1.1.3. brentshaw: Connection established. brentshaw: Sent key-exchange init (KEXINIT), wait response. brentshaw: Algorithms, c->s: 3des-cbc hmac-sha1 none brentshaw: Algorithms, s->c: 3des-cbc hmac-sha1 none brentshaw: Entering Diffie-Hellman Group 1 key exchange. brentshaw: Sent DH public key, waiting for reply. brentshaw: Received host key, type 'ssh-dss'. brentshaw: Host 'xxx.xxx.xxx.xxx' is known and matches the host key. brentshaw: Computing shared secret key. brentshaw: Verifying server signature. brentshaw: Waiting for NEWKEYS message. brentshaw: Send NEWKEYS. brentshaw: Enabling encryption/MAC/compression. brentshaw: Sending request for user-authentication service. brentshaw: Service accepted: ssh-userauth. brentshaw: Trying empty user-authentication request. brentshaw: Authentication methods that can continue: gssapi-keyex,gssa +pi-with-mic,publickey,password,keyboard-interactive. brentshaw: Next method to try is publickey. brentshaw: Next method to try is password. brentshaw: Trying password authentication. brentshaw: Login completed, opening dummy shell channel. brentshaw: channel 0: new [client-session] brentshaw: Requesting channel_open for channel 0. brentshaw: channel 0: open confirm rwindow 0 rmax 32768 brentshaw: Got channel open confirmation, requesting shell. brentshaw: Requesting service shell on channel 0. brentshaw: channel 1: new [client-session] brentshaw: Requesting channel_open for channel 1. brentshaw: Entering interactive session. brentshaw: Sending command: pwd brentshaw: Sending command: pwd brentshaw: Requesting service exec on channel 1. brentshaw: channel 1: open confirm rwindow 0 rmax 32768

I'm not sure why brentshaw: Sending command: pwd appears twice in the debug messages, but it does.

Cheers,

Brent

-- Yeah, I'm a Delt.