perlssh-keysopensshperlnetssh

Perl Net::SSH2 How to Change the Host Key Algorithms/Typ?


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.


Solution

  • 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')