2

We have a working Perl Program that connects to a Server of a Costumer via Net::SSH2 with an ssh-rsa public and private key pair and automatically downloads some Files that are then proceeded by our System. Now the customer communicated that they would no longer support ssh-rsa as a host key only ssh-ed25519, rsa-sha2-512 or rsa-sha2-256.

Apparently the Host key is something different compared to the public and private key and when I talked to our Customer they said that is something we have to change on our Side. I have no Idea how to do that. The only thing I found is the remote_hostkey and/or check_hostkey command, with this I figured out that our host key is indeed of the ssh-rsa type. Is there a way to change that Host Key Algorithms/Type?

As an Alternative, I tried using the Net::SSH::Perl Module. The only one I found that supports more Host Key Algorithms, but it has a lot of other Problems like our public key is not accepted because it is in the OpenSSH Format.

  • More information on host keys here: https://www.ssh.com/blog/what-are-ssh-host-keys – Håkon Hægland Feb 10 '23 at 11:03
  • I think that if you use a version of Net::SSH2 compiled against a recent version of libssh2 it should support at least ssh-ed25519. – salva Feb 11 '23 at 00:24
  • 1
    @Salva I tried doing that and succeeded in compiling it against the most recent Version of libssh2, but there is no way to specific it in NET::SSH2 `my $hostkey = $ssh2->method('HOSTKEY', 'ssh-ed25519');` is not accepted it only takes ssh-dss or ssh-rsa. – theevilking Feb 13 '23 at 10:54

1 Answers1

2

I managed to compile it against libssh2 1.10.0 and got it to work correctly the following way:

  1. Install: Visual Studio Community Edition (Tools for C++ and Windows 10 SDK), CMake, OpenSSL 1.1.1n 64-Bit
  2. compile libssh2 with script from following Link : https://wiert.me/2017/05/09/building-libssh2-for-windows-win32win64-is-a-lot-harder-than-i-hoped-for/
  3. rename \libssh2-1.10.0\buildWin64\example\Debug\libssh2.dll to libssh2-1__.dll and replace in your Strawberry Perl Directory
  4. copy C:\Windows\System32\libcrypto-1_1-x64.dll to PerlSB\perl\vendor\lib\auto\Net\SSH2\libcrypto-1_1-x64.dll and PerlSB\perl\site\lib\auto\Net\SSH2\libcrypto-1_1-x64.dll (same Folder as SSH2/SSH2.xs.dll)
  5. define the hostkey-typ in your Perl Program with $ssh2->method('HOSTKEY', 'ssh-ed25519')