Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

SSH2 Connection issue with Net::SSH:Perl

by sparkyichi (Deacon)
on Jul 20, 2005 at 21:38 UTC ( #476625=perlquestion: print w/replies, xml ) Need Help??
sparkyichi has asked for the wisdom of the Perl Monks concerning the following question:

For the Life of me I can not figure out why I can't get the following code to work. I know the destination is running ssh 2 and I can SSH to it.

#!/usr/bin/perl -w use Net::SSH::Perl; use strict; my (%params, $ssherr, $sshexit); $params{'protocol'} = '2'; $params{'port'} = '22'; $params{'debug'} = 'true'; $params{'interactive'} = 'true'; $params{'compression'} = 'false'; $params{'identity_files'} = [$ENV{HOME}."/.ssh/id_rsa"]; $params{'options'} = ["RSAAuthentication yes", "PasswordAuthentication no", "ConnectTimeout 10", "BatchMode no", "FallBackToRsh no", "RhostsAuthentication no", "RhostsRSAAuthentication no", "KeepAlive yes"]; my $sshconn = Net::SSH::Perl->new("secsscsr01", %params); $sshconn->login('user', 'password'); my ($out1, $err1, $exit2) = $sshconn->cmd("ls -l"); if ($out1){print "Output:\n$_\n\n";} if ($err1){print "Error:\n$_\n\n";} print "Exit Code:\n$exit2\n\n";

I get the following when it is executed:
comops:~/tkl # perl -w ./ comops: Reading configuration data /root/.ssh/config comops: Reading configuration data /etc/ssh_config comops: Allocated local port 1023. comops: Connecting to secsscsr01, port 22. comops: Remote protocol version 2.0, remote software version OpenSSH_3 +.6.1p2 comops: Net::SSH::Perl Version 1.25, protocol version 2.0. comops: No compat match: OpenSSH_3.6.1p2. comops: Connection established. comops: Sent key-exchange init (KEXINIT), wait response. comops: Algorithms, c->s: 3des-cbc hmac-sha1 zlib comops: Algorithms, s->c: 3des-cbc hmac-sha1 zlib comops: Entering Diffie-Hellman Group 1 key exchange. comops: Sent DH public key, waiting for reply. Connection closed by remote host. at /usr/lib/perl5/site_perl/5.8.3/Ne +t/SSH/Perl/Kex/ line 41


Replies are listed 'Best First'.
Re: SSH2 Connection issue with Net::SSH:Perl
by jasonk (Parson) on Jul 21, 2005 at 19:01 UTC

    What is the machine you are trying to login to? I ran into this problem several months ago trying to use version 2 to login to a windows/cygwin host. I found dozens of references to people having similar problems with Net::SSH::perl and Windows together, but never did find a solution, I ended up solving it by using something other than ssh, which worked for my needs at the time...

    We're not surrounded, we're in a target-rich environment!
      I am trying to get it to work from Linux Suse9.1 (My Workstation) to AIX 5.1.

Re: SSH2 Connection issue with Net::SSH:Perl
by schoover (Initiate) on Sep 27, 2005 at 13:17 UTC
    Sparky did you ever make any advances on this problem? I am also stuck on this, regardless of what the host/client OS's are, it always ends up the same way....really really frustrating. Scott Hoover
      No, I decided to work on this later. I will probably find another method.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://476625]
Approved by Tanktalus
Front-paged by planetscape
[marto]: clever stuff
[Corion]: marto: Thanks for pointing me to Tinc - I found at least some article that suggests that what I want would be possible with Tinc. Now I can try that out :)
[marto]: I think you can do what you want without too much hassle, but yeah, please try and let me know if it works well :)
[marto]: sadly I've still not remembered the name of that x86 all in one we discussed
[Corion]: marto: Heh - I looked at the Intel things and they were all at EUR 80 or upwards, and that's a bit too much (or rather, for that money, I'd look for a NAS already)

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2018-01-17 15:13 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (201 votes). Check out past polls.