BernieC has asked for the wisdom of the Perl Monks concerning the following question:

I'm running a program that i've used for years. I just upgraded to the latest version of STrawberry perl on win10/pro, which might be the source of my problem. But this code:
my $ssh2 = Net::SSH2->new() ; $ssh2->connect(HOST) or $ssh2->die_with_error ; $ssh2->check_hostkey(tofu => HOSTKEY) or $ssh2->die_with_error ;
gets me the error
Host key verification failed: unable to perform the check (-46 LIBSSH2 +_ERROR_KNOWN_HOSTS)

Replies are listed 'Best First'.
Re: error_know_host error
by Corion (Patriarch) on Oct 16, 2023 at 16:16 UTC

    Your usage does not match the usage as shown in the documentation. Maybe try it like this:

    $ssh2->check_hostkey(LIBSSH2_HOSTKEY_POLICY_TOFU) or $ssh2->die_with_error;

    Also, have you verified (using plain ssh) that the hostkey is still the same as in your known_hosts file?

      Should Net::SSH2 have defined that? I got: Bareword "LIBSSH2_HOSTKEY_POLICY_TOFU" not allowed while "strict subs" in use
        it's not properly documented, but based on Net/SSH2.pm source, it requires Net/SSH2/Constants.pm, which sets up export tags, including :policy which includes LIBSSH2_HOSTKEY_POLICY_TOFU -- so I think that use Net::SSH2 qw/:policy/; should work for you (untested).