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

use 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$
Do I miss something? Any help from you is appreciated

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
    It appears that the SERVER you are connecting to only supports SSH using the deprecated "ssh-dss" algorithm.

    A note at https://www.gentoo.org/support/news-items/2015-08-13-openssh-weak-keys.html says:

    Starting with the 7.0 release of OpenSSH, support for ssh-dss keys has been disabled by default at runtime due to their inherit weakness.

    Similarly, openssh says :OpenSSH 7.0 and greater similarly disables the ssh-dss (DSA) public key algorithm. It too is weak and we recommend against its use. It can be re-enabled using the HostkeyAlgorithms configuration option.

    If you cannot fix the server, you can google around and enable the local ssh-dss algorithm on the client.

            This is not an optical illusion, it just looks like one.