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

I have a program that I've used for *years*. I recently updated Strawberry Perl to v5.38.0, and when I run it I get Unable to determine known_hosts location (-16 LIBSSH2_ERROR_FILE) The code looks like
my $ssh2 = Net::SSH2->new() ; $ssh2->connect(HOST) or $ssh2->die_with_error ; # $ssh2->check_hostkey(tofu => HOSTKEY) $ssh2->check_hostkey("LIBSSH2_HOSTKEY_POLICY_TOFU") or $ssh2->die_with_error ; $ssh2->auth_publickey(USER, PUBLICKEY, PRIVATEKEY) or $ssh2->die_with_error ; $ssh2->auth_ok() ;
The error is on the check_hostkey line. I wrote this program long ago and I neither know why it stopped working nor what is wrong. Apparently "back in the day" it know how to find the known_hosts but now it doesn't

Replies are listed 'Best First'.
Re: Unable to determine known_hosts location (-16 LIBSSH2_ERROR_FILE)
by choroba (Cardinal) on Oct 18, 2023 at 17:17 UTC
      Hello choroba,

      most routines of this family are not implemented in win32 perl

      L*

      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re: Unable to determine known_hosts location (-16 LIBSSH2_ERROR_FILE)
by kcott (Archbishop) on Oct 18, 2023 at 17:47 UTC

    G'day BernieC,

    I'm not a user of Net::SSH2, but looking at its documentation and its source it would seem LIBSSH2_HOSTKEY_POLICY_TOFU should be a constant: try removing the quotes.

    If that doesn't work, providing additional information may help others to troubleshoot your problem.

    • Does your code have a use VERSION? If so, what is it?
    • With no use VERSION or VERSION < v5.12, you should include strict and warnings; with VERSION >= v5.12 and < v5.36, you should include warnings (you automatically get strict); with VERSION >= v5.36, you automatically get strict and warnings. What does your code have?
    • What version of Perl relates to "back in the day"?
    • What was the previous version of Net::SSH2 you used? What is the current version?
    • Net::SSH2 is not a core module. Did you install it with your new v5.38.0?
    • What version of libssh2 do you have installed?

    See also: "Net::SSH2: Error handling"; in particular, its reference to check_hostkey.

    — Ken

      it would seem LIBSSH2_HOSTKEY_POLICY_TOFU should be a constant: try removing the quotes.

      Just as discussed 2 days ago in the original thread.


      🦛

        ++ I thought it sounded familiar; couldn't pinpoint it though. Thanks.

        — Ken

        Bareword "LIBSSH2_HOSTKEY_POLICY_TOFU" not allowed while "strict subs" in use