James Xu has asked for the wisdom of the Perl Monks concerning the following question:
I’m trying to use Perl to develop some scripts. The script use the Net::SSH::Perl module to establish a SSH connect.
Unluckily, I fail to do that. It raised an error prompt, say‘No hostkey algorithm!’ and return silently. I’m a new hand at Perl script. Could you do me a favor to help me resolve this issue? Thank you in advance.
Below are something I dumped from my Linux Ubuntu 16.04 LST.
1, Net::SSH::Perl v2 was installed
james@trail:~/perl$ perldoc -lm Net::SSH::Perl /usr/local/lib/i386-linux-gnu/perl/5.22.1/Net/SSH/Perl.pm james@trail:~/perl$ james@trail:~/perl$
2. report No hostkey algorithm! While executing the script connecting a device.
james@trail:~/perl$ perl ssh.pl
trail: Reading configuration data /home/james/.ssh/config
trail: Reading configuration data /etc/ssh_config
trail: Connecting to 172.27.90.48, port 22.
trail: Remote version string: SSH-2.0-ConfD-5.3.6
trail: Remote protocol version 2.0, remote software version ConfD-5.3.6
trail: Net::SSH::Perl Version 2.01, protocol version 2.0.
trail: No compat match: ConfD-5.3.6.
trail: Connection established.
trail: Sent key-exchange init (KEXINIT), waiting for response.
trail: Using diffie-hellman-group-exchange-sha256 for key exchange
No hostkey algorithm! CLIENT: ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa SERVER ssh-dss at /usr/local/lib/i386-linux-gnu/perl/5.22.1/Net/SSH/Perl/SSH2.pm line 118.
3. I’ve add a HostkeyAlgorithms ssh-dss in ssh config
james@trail:~/perl$ cat ~/.ssh/config HostkeyAlgorithms ssh-dss #HostkeyAlgorithms ssh-ed25519 #HostkeyAlgorithms ssh-rsa
4. here is script james@trail:~/perl$ cat ssh.pl
Do I miss something? Any help from you is appreciateduse Net::SSH::Perl; #use Net::SSH::Perl::Auth; my $host='172.27.90.48'; my $user='admin'; my $passwd='admin'; my $ssh = Net::SSH::Perl->new($host,port=>22,debug=>1); $ssh->login($user,$passwd); my ($stdout,$stderr,$exit) = $ssh->cmd("date"); $ssh->cmd("exit"); if($stderr){ print "ErrorCode:$exit\n"; print "ErrorMsg:$stderr"; } else { print $stdout; } exit $exit; james@trail:~/perl$
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 'No hostkey algorithm!' issue while using Net::SSH::Perl
by NetWallah (Canon) on May 12, 2016 at 06:09 UTC |