in reply to Re^3: instantiating an SFTP object
in thread instantiating an SFTP object

After connect you should call check_hostkey. For instance:
$ssh2->check_hostkey(LIBSSH2_HOSTKEY_POLICY_ASK);

Replies are listed 'Best First'.
Re^5: instantiating an SFTP object
by zentara (Cardinal) on Jun 13, 2017 at 19:29 UTC
    Hi, I don't want to feel like a dufus, but I tried
    my $return = $ssh2->check_hostkey(LIBSSH2_HOSTKEY_POLICY_ASK); print "Return: $return\n\n\n\n";
    and all I get is Return 00 and the normal filehandle printout. How exactly do I efficiently print out the returns from the check_hostkey command.? I'm cultivating laziness. :-)

    I'm not really a human, but I play one on earth. ..... an animated JAPH
      If the remote host key is good enough for the given policy, the method returns a true value. Otherwise it returns undef and the error (or die_with_error) method can be used to find out the failure cause.
      $ssh2->check_hostkey(LIBSSH2_HOSTKEY_POLICY_ASK) or $ssh2->die_with_error;
      The 0-but-true value 00 is equal to LIBSSH2_KNOWNHOST_CHECK_MATCH.
        The 0-but-true value 00 is equal to LIBSSH2_KNOWNHOST_CHECK_MATCH.

        That's good isn't it? :-)


        I'm not really a human, but I play one on earth. ..... an animated JAPH