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

In reply to 'No hostkey algorithm!' issue while using Net::SSH::Perl by James Xu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.