I am trying to implement a secure FTP transfer to a remote machine. The remote machine does NOT permit an SSH telnet session, but will allow SFTP sessions. I am able to connect using the command line 'sftp'. However when connecting to the same machine using Net::SFTP I get the following error messages:

local: Connecting to ***********, port 22.
local: Remote protocol version 2.0, remote software version OpenSSH_3.0.2p1
local: Net::SSH::Perl Version 1.23, protocol version 2.0.
local: No compat match: OpenSSH_3.0.2p1.
local: Connection established.
local: Sent key-exchange init (KEXINIT), wait response.
local: Algorithms, c->s: 3des-cbc hmac-sha1 none
local: Algorithms, s->c: 3des-cbc hmac-sha1 none
local: Entering Diffie-Hellman Group 1 key exchange.
local: Sent DH public key, waiting for reply.
local: Received host key, type 'ssh-dss'.
local: Host '****************' is known and matches the host key.
local: Computing shared secret key.
local: Verifying server signature.
local: Waiting for NEWKEYS message.
local: Enabling incoming encryption/MAC/compression.
local: Send NEWKEYS, enable outgoing encryption/MAC/compression.
local: Sending request for user-authentication service.
local: Service accepted: ssh-userauth.
local: Trying empty user-authentication request.
local: Authentication methods that can continue: publickey.
local: Next method to try is publickey.
Permission denied at /opt/perl/lib/site_perl/5.6.1/Net/SFTP.pm line 37

Line 37 of SFTP.pm is:

$ssh->login($param{user}, $param{password});

The remote SFTP host uses public/private keys and only needs a username (ie. user@host) to login - all of which is in my code:

use Net::SFTP; my %args = (ssh_args => []); $args{user} = $user; push @{ $args{ssh_args} }, port => 22; my $sftp = Net::SFTP->new($host,%args);
Any ideas what the problem might be?

In reply to Net::SFTP permission denied but sftp works by Anonymous Monk

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.