Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Net::SSH::Perl and protocol 2?

by Anonymous Monk
on May 08, 2002 at 16:16 UTC ( #165087=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks -

From my Linux box I'm trying to use Net::SSH::Perl to run a command on a remote Windows box running OpenSSH-3.1 and the CygWin environment. From Linux if I do 'ssh -2 -l configadm <windows ip> "/bin/ls /"', everything works perfectly, so I would think the following code should also work:

#!/usr/bin/perl -w use Net::SSH::Perl; use strict; my $ip = "<windows ip>"; my $pw = "<password>"; my $user = 'configadm'; my $ssh = Net::SSH::Perl->new($ip, protocol=>2); my ($stdout, $stderr, $exit); eval { $ssh->login($user,$pw); ($stdout, $stderr, $exit) = $ssh->cmd('/bin/ls /'); }; if ($@) { die "@@@@@ failed login or command problem"; } print $stdout; exit 0;
The problem is that nothing ever comes back over the ssh session, so $stdout does not get populated. If I execute the same code against a unix box running openssh then everything works perfectly. So, I'm left with either a bug in Net::SSH::Perl, a bug in CygWin, or a bug in OpenSSH for windows or some combination. It works from the command line though, so where does that leave us?

--Mike

Comment on Net::SSH::Perl and protocol 2?
Download Code
(RhetTbull) Re: Net::SSH::Perl and protocol 2?
by RhetTbull (Curate) on May 08, 2002 at 16:49 UTC
    I tried your code using Net::SSH::Perl version 1.23 with cygwin version 1.3.10 and openssh version 3.1p1-1 running on Windows 2000. It worked fine. Are you using the latest version of Net::SSH::Perl? Are you sure your openssh server is configured properly?
      Thanks for the reply.

      I'm running the same versions of the software you mention above (Net::SSH::Perl 1.23, cygwin 1.3.10, and openssh 3.1p1) except for openssh I think since you said "openssh 3.1.p1-1. Anyway, the fact that it works on your system seems to narrow it down to a configuration issue on my side, but it works perfectly from the command line so I'm not sure what to look for.
Re: Net::SSH::Perl and protocol 2?
by runrig (Abbot) on May 08, 2002 at 20:27 UTC
    Try turning the debug option on, and see what it says.
    ------------
    ooo  O\O  ooo tilly was here :,(
    
Re: Net::SSH::Perl and protocol 2?
by Anonymous Monk on Jun 13, 2002 at 13:39 UTC
    Make sure the windows box is in the .ssh/knwon_hosts file of the uid the program is running under. -martin

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://165087]
Approved by dsb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2015-07-03 07:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (48 votes), past polls