I am trying to use Net::SFTP to download a file. I am using public key authentication, but the authentication seems to fail. If I use line command sftp (sftp userid@hostname) I have no problems connecting and sending a file. Both the line command sftp and Net::SFTP::perl are using SSH2. Here is a snipit of my code:
use Net::SFTP; use Net::SFTP::Util qw(fx2txt); %args = ( user => "thisuser", debug => 1, protocol => 2 ); $host = $ARGV[0]; $ftp = Net::SFTP->new($host, %args);
Below is the debug log. It appears that the public key authentication fails so it tries password authentication. Password authentication is not an option for this application. Anyone have any ideas how I can fix this?
server1: Reading configuration data /abc/userid/.ssh/config server1: Reading configuration data /etc/ssh_config server1: Connecting to xxxxxxxx.xxxx.xxx, port 22. server1: Remote version string: SSH-2.0-WS_FTP-SSH_6.1.1 server1: Remote protocol version 2.0, remote software version WS_FTP- +SSH_6.1.1 server1: Net::SSH::Perl Version 1.30, protocol version 2.0. server1: Connection established. server1: Sent key-exchange init (KEXINIT), wait response. server1: Algorithms, c->s: 3des-cbc hmac-sha1 none server1: Algorithms, s->c: 3des-cbc hmac-sha1 none server1: Entering Diffie-Hellman Group 1 key exchange. server1: Sent DH public key, waiting for reply. server1: Received host key, type 'ssh-dss'. server1: Host 'xxxxxxx.xxxx.xxx' is known and matches the host key. server1: Computing shared secret key. server1: Verifying server signature. server1: Waiting for NEWKEYS message. server1: Enabling incoming encryption/MAC/compression. server1: Send NEWKEYS, enable outgoing encryption/MAC/compression. server1: Sending request for user-authentication service. server1: Service accepted: ssh-userauth. server1: Trying empty user-authentication request. server1: Authentication methods that can continue: publickey,password +. server1: Next method to try is publickey. server1: Trying pubkey authentication with key file '/abc/userid/.ssh +/id_dsa' server1: Authentication methods that can continue: publickey,password +. server1: Next method to try is publickey. server1: Next method to try is password. server1: Trying password authentication. server1: Will not query passphrase in batch mode. server1: Login completed, opening dummy shell channel. server1: channel 0: new [client-session] server1: Requesting channel_open for channel 0. server1: channel 0: open confirm rwindow 300000 rmax 30000 server1: channel 1: new [client-session] server1: Requesting channel_open for channel 1. server1: Sending subsystem: sftp server1: Requesting service subsystem on channel 1. server1: channel 1: open confirm rwindow 300000 rmax 30000 server1: sftp: Sending SSH2_FXP_INIT server1: sftp: Remote version: 3
Thanks for any help you can give.

In reply to Net::SFTP authentication problem by SeekerOfTruth

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.