Nalina has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks,
I tried to execute some commands on firewall using ssh.
Following is my script
#!/usr/bin/perl -w # $Id: cmd.pl,v 1.4 2001/02/22 00:14:48 btrott Exp $ + use strict; + use Net::SSH::Perl; use Net::SSH::Perl::Cipher; + chomp(my $this_host = `hostname`); print "Enter a host name to connect to: [$this_host] "; chomp(my $host = <STDIN>); print "\n"; + print "Enter the port number of the remote sshd: [ssh] "; chomp(my $port = <STDIN>); print "\n"; + print "Choose a cipher from the list:\n"; my $supp = Net::SSH::Perl::Cipher::supported(); for my $ciph (sort @$supp) { printf " [%d] %s\n", $ciph, Net::SSH::Perl::Cipher::name($ciph) +; } printf "Enter a number: [%d] ", Net::SSH::Perl::Cipher::id('IDEA'); chomp(my $c = <STDIN>); print "\n"; my $ssh = Net::SSH::Perl->new($host || $this_host, port => $port || 'ssh', cipher => Net::SSH::Perl::Cipher::name($c), debug => 1); + my $this_user = scalar getpwuid($<); print "Enter your username on that host: [$this_user] "; chomp(my $user = <STDIN>); + use Term::ReadKey; + print "And your password: "; ReadMode('noecho'); chomp(my $pass = ReadLine(0)); ReadMode('restore'); print "\n"; + $ssh->login($user || $this_user, $pass); + print "Enter a command to execute: [ls -l] "; chomp(my $cmd = <STDIN>); my($out, $err) = $ssh->cmd($cmd || "ls -l"); print $out;
the cipher selected is 'DES'. With debug=1, after line 'Linux: Received encryption confirmation.' I got an error saying 'input must be 8 bytes long at /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/Crypt/DES.pm line 57.'
How do i correct this?
Thanks
Nalina
20040611 Edit by Corion: Added code tags, reformatted
20040611 Edit by Corion: Changed title from 'Please help me'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::SSH::Perl Error: 'input must be 8 bytes long'
by eXile (Priest) on Jun 11, 2004 at 13:37 UTC | |
|
Re: Net::SSH::Perl Error: 'input must be 8 bytes long'
by Joost (Canon) on Jun 11, 2004 at 12:41 UTC |