rajar has asked for the wisdom of the Perl Monks concerning the following question:

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'

Replies are listed 'Best First'.
Re: log into FTP server using Net::SFTP
by explorer (Chaplain) on Jan 30, 2006 at 20:34 UTC
    Hummm.... is possible you need to add the option PasswordAuthentication yes to /etc/ssh/sshd_config at server side...
      Thanks for the reply.
      I added that and it didn't fix it. It is throwing the same error.

      Thanks
      Raja

Re: log into FTP server using Net::SFTP
by zentara (Cardinal) on Jan 30, 2006 at 20:46 UTC
    Just a nit-pick. Maybe you should change the node title? I don't think you can log on to an FTP server with STFP. Different protocols entirely.

    I'm not really a human, but I play one on earth. flash japh