I have an application that is using Net::SSH::Perl to login to hosts and collect data. It has been working fine on all the unix/linux hosts that we have, but now I'm extending it to get data from windows boxes using the cygwin ssh server, and although it seems to be able to login to the windows machines fine, running commands on those machines fails.
use Net::SSH::Perl; my($hostname,$username,$password,$debug) = @ARGV; my $ssh = Net::SSH::Perl->new( $hostname, protocol => '2,1', debug => $debug, ); $ssh->login($username,$password); my($out,$err,$ext) = $ssh->cmd("echo LOGINSUCCESSFUL"); print "out=$out err=$err ext=$ext\n";
% ./test.pl linux-host root password Use of uninitialized value in concatenation (.) or string at ./test.pl + line 16. out=LOGINSUCCESSFUL err= ext=0
% ./test.pl windows-host Administrator password Use of uninitialized value in concatenation (.) or string at ./test.pl + line 16. Use of uninitialized value in concatenation (.) or string at ./test.pl + line 16. out= err= ext=255
Using the command line ssh client works fine for both hosts
% ssh -2 root@linux-host "echo LOGINSUCCESFUL" root@linux-host's password: LOGINSUCCESFUL % ssh -2 Administrator@windows-host "echo LOGINSUCCESFUL" Administrator@windows-host's password: LOGINSUCCESFUL
When turning debugging on, the debug output looks identical (with the exception of host names and OpenSSH version numbers). I've also tried specifying the full path to echo which doesn't have any effect. The OpenSSH version on the linux server I tested is 3.1p1 (although the application as it is currently in production runs against many different implementations and versions of ssh on linux, hpux, and solaris hosts), and the OpenSSH version on my windows test host is 3.8p1.
I've found that the one thing I can do which does make this work is to change the protocol specification from 2,1 to 1,2. This has serious impact on performance however, as using protocol 1 means that a new connection is created every time that cmd() is called, and this application may call it hundreds of times for a given host. I also don't have the option of only changing the protocol for the windows hosts, as I don't have any way to identify in advance what the host is running.
Anybody have any additional ideas on how to get this to work with a cygwin server using protocol version 2?
| We're not surrounded, we're in a target-rich environment! |
|---|
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |