Hello all:
I am trying to log into a FTP server using Net::SFTP and I cannot seem to get it to work.
It is not a problem with the account as I am able to log in to the remote FTP server via the sftp command. The authentication there is just a username and password.


Any help would be greatly appreciated.
Here is my connect method:

sub connect { my ($pserver,$puser,$ppass)=@_; warn "-----------------Entering connect--------------------"; #Connect and login to the server my $port = 22; my %args = (ssh_args => []); $args{user} = $puser; $args{password} = $ppass; $args{debug} = 1; $args{protocol} = '2,1'; push @{ $args{ssh_args} }, port => $port; my $pftp = Net::SFTP->new($pserver,%args) or die "Cannot conne +ct to $pserver: $@"; warn "------------------Connected--------------------"; $pftp->login($puser,$ppass) or die "Cannot login ", $pftp->me +ssage; warn "return from connect"; return $pftp; }
And here is the output:

-----------------Entering connect-------------------- at ./checkftp li +ne 31. : Reading configuration data /home/sbiadmin/.ssh/config xxxxxxserver: Reading configuration data /etc/ssh_config xxxxxxserver: Connecting to xxx.xxx.xxx.87, port 22. xxxxxxserver: Remote protocol version 2.0, remote software version 3.1 +.2 SSH Secure Shell Windows NT Server xxxxxxserver: Net::SSH::Perl Version 1.29, protocol version 2.0. .yyyyyserver: No compat match: 3.1.2 SSH Secure Shell Windows NT Serve +r xxxxxxserver: Connection established. xxxxxxserver: Sent key-exchange init (KEXINIT), wait response. xxxxxxserver: Algorithms, c->s: 3des-cbc hmac-sha1 none xxxxxxserver: Algorithms, s->c: 3des-cbc hmac-sha1 none xxxxxxserver: Entering Diffie-Hellman Group 1 key exchange. xxxxxxserver: Sent DH public key, waiting for reply. xxxxxxserver: Received host key, type 'ssh-dss'. xxxxxxserver: Host 'xxx.xxx.xxx.87' is known and matches the host key. xxxxxxserver: Computing shared secret key. xxxxxxserver: Verifying server signature. xxxxxxserver: Waiting for NEWKEYS message. xxxxxxserver: Enabling incoming encryption/MAC/compression. xxxxxxserver: Send NEWKEYS, enable outgoing encryption/MAC/compression +. xxxxxxserver: Sending request for user-authentication service. xxxxxxserver: Service accepted: ssh-userauth. xxxxxxserver: Trying empty user-authentication request. xxxxxxserver: Authentication methods that can continue: publickey,pass +word. xxxxxxserver: Next method to try is publickey. xxxxxxserver: Next method to try is password. xxxxxxserver: Trying password authentication. xxxxxxserver: Authentication methods that can continue: publickey,pass +word. xxxxxxserver: Next method to try is publickey. xxxxxxserver: Next method to try is password. xxxxxxserver: Trying password authentication. xxxxxxserver: Authentication methods that can continue: publickey,pass +word. xxxxxxserver: Next method to try is publickey. xxxxxxserver: Next method to try is password. xxxxxxserver: Trying password authentication. xxxxxxserver: Authentication methods that can continue: publickey. xxxxxxserver: Next method to try is publickey. Permission denied at /usr/local/share/perl/5.8.7/Net/SFTP.pm line 62

2006-01-30 Retitled by Arunbear, as per Monastery guidelines
Original title: 'Net::SFTP'


In reply to Log into FTP server over SSH using Net::SFTP by rajar

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.