I have a wrapper script which I wrote to work around hanging TTY issues when starting tomcat over SSH, but upong upgrading my system, it seems to have horribly broken key authentication. Here's the relevant snippet of perl code:

my %SSH_Prm = ( "protocol" => '2', "use_pty" => 0, "options" => ["stricthostkeychecking no"], "identity_files" => ["/home/user/.ssh/id_rsa"], "debug" => 1, ); my $ssh = Net::SSH::Perl->new($server,%SSH_Prm); $ssh->login("deploy"); my ($out,$err,$exit) = $ssh->cmd("/usr/bin/sudo $command");

The debug was added to get more detailed diagnostic data, which now shows:

server.domain.net: Authentication methods that can continue: publickey +. server.domain.net: Next method to try is publickey. server.domain.net: Trying pubkey authentication with key file '/home/u +ser/.ssh/id_rsa' server.domain.net: Authentication methods that can continue: publickey +. server.domain.net: Next method to try is publickey. Permission denied at ./start_tomcat_remote line 88

Now if I test this ssh key authentication using OpenSSH, it works without issue:

ssh -vv -i /home/user/.ssh/id_rsa deploy@server.domain.net ... debug1: Offering public key: /home/user/.ssh/id_rsa debug2: we sent a publickey packet, wait for reply debug1: Server accepts key: pkalg ssh-rsa blen 277

Now to my eye, this is a very straightforward perl module failure, but I'm not getting enough information to figure out how to fix it. I've read through other perlmonks issues with Net::SSH::Perl and have found issues with password auth, but nothing else using pre-determined keys. Any idea what I might do next to resolve this?


In reply to Key Auth problem with Net::SSH::Perl by CanisAnubis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.