Hm... further investigations make me think there's a bug in Net::SSH::Perl or Net::SFTP.

try adding this to your code:

my %args = ( user => 'user', password => 'password', ssh_args => [ debug => 1, options => [ "PreferredAuthentications 'keyboard-interactive,password,h +ostbased,publickey'", ] ], );
and then:
eval { $sftp = Net::SFTP->new($host, %args) }; die "Connection failed: $!\n" if $!; die "No SFTP object\n" unless $sftp;
my output goes like:
wolf: Reading configuration data /home/insaniac/.ssh/config wolf: Reading configuration data /etc/ssh_config wolf: Connecting to bear, port 22. wolf: Remote protocol version 2.0, remote software version OpenSSH_4.2 +p1 Debian-4 wolf: Net::SSH::Perl Version 1.28, protocol version 2.0. wolf: No compat match: OpenSSH_4.2p1 Debian-4. wolf: Connection established. wolf: Sent key-exchange init (KEXINIT), wait response. wolf: Algorithms, c->s: 3des-cbc hmac-sha1 none wolf: Algorithms, s->c: 3des-cbc hmac-sha1 none wolf: Entering Diffie-Hellman Group 1 key exchange. wolf: Sent DH public key, waiting for reply. wolf: Received host key, type 'ssh-dss'. wolf: Host 'bear' is known and matches the host key. wolf: Computing shared secret key. wolf: Verifying server signature. wolf: Waiting for NEWKEYS message. wolf: Enabling incoming encryption/MAC/compression. wolf: Send NEWKEYS, enable outgoing encryption/MAC/compression. wolf: Sending request for user-authentication service. wolf: Service accepted: ssh-userauth. wolf: Trying empty user-authentication request. wolf: Authentication methods that can continue: publickey,keyboard-int +eractive. wolf: Next method to try is publickey. wolf: Trying pubkey authentication with key file '/home/insaniac/.ssh/ +id_dsa' wolf: Authentication methods that can continue: publickey,keyboard-int +eractive. wolf: Next method to try is publickey. Connection failed: No such file or directory

So when I try authenticating with an ssh-key, all works out perfectly. When I try to supply a username and a password, they seem to be ignored.. maybe we need to supply a specific value to ssh_args ?
Per default, Net::SFTP uses the username that's executing the script as SSH username...

I'll keep you informed if I find a solution...

Cheers, Johnny

to ask a question is a moment of shame
to remain ignorant is a lifelong shame


In reply to Re^7: sftp->do_write howto? by insaniac
in thread sftp->do_write howto? by chrism01

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.