in reply to Net SSH2 auth_publickey not working in Windows

You might try and see if an error message is printed to the console
$ssh2->auth_publickey('username', 'openssh.public', 'openssh.private.ppk') or die "$!\n";

I'm not really a human, but I play one on earth Remember How Lucky You Are

Replies are listed 'Best First'.
Re^2: Net SSH2 auth_publickey not working in Windows
by Badhedgehog (Initiate) on May 12, 2011 at 15:31 UTC
    Afternoon all.

    I'm having the same problem as above, same circumstances in that I can use puTTY to get on to the box using key-based authentication. The relevant code is:

    my $ssh = Net::SSH2->new();
    print "DEBUG: 1\n";
    $ssh->debug(1);
    $ssh->connect($config_host);
    print "DEBUG: 2 $SSH_USER\n";
    $ssh->auth_publickey($SSH_USER, './virt_pub', './virt_priv.ppk') or die "pk connection error $!\n";
    #$ssh->auth_password($SSH_USER, "some_password");
    print "DEBUG: 3\n";
    my $channel = $ssh->channel();
    print "DEBUG: 4 $ssh->error()\n";


    At the ->auth_publickey call I get the message 'Resource temporarily unavailable'.

    Does anyone know which resource? One of the key files or perhaps sshd on the server?

    TIA,

    Nick

    p.s. the auth_password version works
      Right, it's working, thanks to both zentara and salva for gently nudging me in the right direction and apologies for the wetware error

      It was me using the wrong format keys. Once I used the private key generated from puttygen's 'Conversion' menu and the public key from the 'Public key for pasting into OpenSSH authorized_keys file' file all works swimmingly.

      Nick
        HI Nick, i am struggling to get ssh (or ssh2) connection from windows client. I have been trying for more than 3 days but not able to get it work. Can you please share the complete script, utilities you used and the steps you had to perform to get right keys (server and client). I know i am asking for too much but i am really stuck here. using the info from this post, i get "Authentication failed: Permission denied" error. thanks amit
      Hi, I don't use windows, but compare your auth_publickey to mine below.
      $ssh->auth_publickey($SSH_USER, './virt_pub', './virt_priv.ppk') or di +e "pk connection error $!\n";
      # you need permission to read the keys $ssh2->auth_publickey('zentara', '/home/zentara/.ssh/id_dsa.pub', '/home/zentara/.ssh/id_dsa', $pass );
      It's possible that your dot slash notation for specifying the key's path, may need a full path from root. You may not be running from the directory you think you are in.

      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh
        Firstly, thanks for taking the time to reply.

        I've tried a number of variations on a theme for the path including:
        • C:\putty\virt_pub
        • C:/putty/virt_pub
        as well as the relative path in my previous post. All are giving the same 'Resource temporarily unavailable' error.

        A Wireshark capture of the conversation doesn't reveal anything suspicious looking aside from the conversation between the two boxes being a bit short ;).

        Nick