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

I am having issues with the Net::SSH::Perl project. The code I have is:
use strict; use Net::SSH::Perl qw(ssh); my $commection '192.168.1.1'; my $username = 'bob'; my $password = 'password'; print "Starting SSH Services..."; my $ssh = Net::SSH:Perl->New("$Connection"); print "Done\n"; print "Logging in..." $ssh->login("$username", "$password"); print "Done\n"; my $command
I am getting to the password and it is failing at the password. The user name and password are correct. What else could be wrong?

Replies are listed 'Best First'.
Re: Net::SSH Woes
by syphilis (Archbishop) on Feb 23, 2008 at 10:20 UTC
    Have you considered using Net::SSH2 instead ? It requires the libssh2 library - and is more in keeping with *my* notion of how perl ought to be interfaced with SSH2.

    Of course, that view might not be shared by others. I note that both Net::SSH::Perl and Net::SSH2 are maintained by the same guy - it would be interesting to know which, of the two options, *he* recommends (re the SSH2 protocol). I don't think he's on perlmonks, though.

    Cheers,
    Rob
Re: Net::SSH Woes
by proceng (Scribe) on Feb 23, 2008 at 14:16 UTC
    use warnings; use strict; use Net::SSH::Perl qw(ssh); #my $commection '192.168.1.1'; my $connection '192.168.1.1'; my $username = 'bob'; my $password = 'password'; print "Starting SSH Services..."; #my $ssh = Net::SSH:Perl->New("$Connection"); my $ssh = Net::SSH:Perl->New("$connection") or die "Connection failed +: $!\n" ; print "Done\n"; # print "Logging in..." #$ssh->login("$username", "$password"); $ssh->login("$username", "$password") or die "Login failed: $!\n"; print "Done\n"; my $command
Re: Net::SSH Woes
by Corion (Patriarch) on Feb 23, 2008 at 09:37 UTC

    The code you posted doesn't even compile.

    Maybe you want to tell us how it does "bomb out", and maybe you even want post the actual code you're using.

Re: Net::SSH Woes
by Khen1950fx (Canon) on Feb 24, 2008 at 02:33 UTC
    Make sure that you have all the dependencies installed properly.

    #!/usr/bin/perl use strict; use warnings; use Net::SSH::Perl; use Net::SSH::Perl::Cipher; my $host = 'localhost.localdomain'; my $username = 'yourusername'; my $password = 'yourpassword'; my $cmd = 'perl -V'; warn "Starting SSH Services..."; my $ssh = Net::SSH::Perl->new($host, debug => 1); print "Done\n"; warn "Logging in..."; $ssh->login($username, $password); print "Done\n"; warn "Starting command..."; my($stdout, $stderr, $exit) = $ssh->cmd($cmd); print $stdout, "\n";
      How can I string commands along using this script?
      $ssh->cmd($cmd); $ssh->cmd($cmd1); or my $cmd = 'Perl -v', 'exit'; $ssh->cmd($cmd);
        #!/usr/bin/perl use strict; no warnings; use Net::SSH::Perl; use Net::SSH::Perl::Cipher; my $host = 'localhost'; my $username = 'yourusername'; my $password = 'yourpassword'; my $cmd = 'perl -V'; my $cmd2 = 'module_info -a Net::SSH::Perl'; my $cmd3 = 'perldoc Net::SSH::Perl'; my $cmd4 = 'exit'; warn "Starting SSH Services..."; my $ssh = Net::SSH::Perl->new($host, debug => 1); print "Done\n"; warn "Logging in..."; $ssh->login($username, $password); print "Done\n"; warn "Starting Command..."; my($stdout, $stderr, $exit) = $ssh->cmd($cmd); print "Done\n"; warn "Starting 2nd Command..."; my($stdout, $stderr, $exit) = $ssh->cmd($cmd2); print "Done\n"; warn "Starting 3rd Command..."; my($stdout, $stderr, $exit) = $ssh->cmd($cmd3); print "Done\n"; warn "Starting 4th Command..."; my($stdout, $stderr, $exit) = $ssh->cmd($cmd4); print "Done\n";
      This worked Great!!! Thanks for your help!