简体   繁体   中英

Net::SFTP::Foreign password authentication error

I'm running the following script to connect to a sftp:

#!/usr/bin/perl
use strict;
use warnings;
use POSIX;
use File::Path qw(make_path);
use File::Copy;
use IO::Handle;
use IO::File;
use Data::Printer;
use Net::SFTP::Foreign;
$Net::SFTP::Foreign::debug = -1;

STDOUT->autoflush(1);
STDERR->autoflush(1);

my ($genCfgFile) = <@ARGV>;

if (!defined($genCfgFile)||($genCfgFile eq '')){
    print "Usage: $0 cfgFile";
    exit(1);
}

my %User_Preferences=readCfgFile($genCfgFile);
    print p(%User_Preferences)."\n";
getFilesFromSFTP(\%User_Preferences);

exit(0);

sub getFilesFromSFTP{
    my ($User_PreferencesHref)=@_;
    my $FtpHost=$User_PreferencesHref->{"FTP_HOST"} or die "Missing parameter FTP_HOST in cfg file.\n";
    my $FtpPort=$User_PreferencesHref->{"FTP_PORT"} or die "Missing parameter FTP_PORT in cfg file.\n";
    my $FtpUser=$User_PreferencesHref->{"FTP_USER"} or die "Missing parameter FTP_USER in cfg file.\n";
    my $FtpPwd=$User_PreferencesHref->{"FTP_PWD"} or die "Missing parameter FTP_PWD in cfg file.\n";

    my %args = (user => $FtpUser, password => $FtpPwd, port => $FtpPort);

    print p(%args)."\n";

    my $sftp= Net::SFTP::Foreign->new($FtpHost, %args) or die "Cannot connect to : $@";
    my $entries = $sftp->ls;
    print p(@$entries)."\n";
}

However, it somewhat fails during the password autenthication, this is the debug log:

#12200 1438942500.00000 new: This is Net::SFTP::Foreign 1.77
#12200 1438942500.00000 new: Loaded from /usr/lib/perl5/site_perl/5.8.5/Net/SFTP/Foreign.pm
#12200 1438942500.00000 new: Running on Perl for linux
#12200 1438942500.00000 new: debug set to -1
#12200 1438942500.00000 new: ~0 is 18446744073709551615
#12200 1438942500.00000 new: Using backend Net::SFTP::Foreign::Backend::Unix 1.76_03
#12200 1438942500.00000 _init_transport: ssh cmd: ssh -p 22 -o NumberOfPasswordPrompts=1 -o PreferredAuthentications=keyboard-interactive,password -l bnp 10.255.235.10 -s sftp

#12200 1438942500.00000 _init_transport: starting password authentication
#12200 1438942500.00000 _init_transport: waiting for data from the pty to become available
#12200 1438942500.00000 _init_transport: 30 bytes readed from pty:
62 6e 70 40 31 30 2e 32 35 35 2e 32 33 35 2e 31 30 27 73 20 70 61 73 73 77 6f 72 64 3a 20 | bnp@10.255.235.10's password:
#12200 1438942500.00000 _init_transport: looking for user/password prompt
#12200 1438942500.00000 _init_transport: matching against (?i-xsm:(user|name|login)?[:?]\s*$)
#12200 1438942500.00000 _init_transport: sending password
#12200 1438942500.00000 _init_transport: waiting for data from the pty to become available
#12200 1438942500.00000 _init_transport: 2 bytes readed from pty:
0d 0a | ..
#12200 1438942500.00000 _init_transport: looking for password ok
#12200 1438942500.00000 _init_transport: password authentication done
#12200 1438942500.00000 _queue_msg: queueing msg len: 5, code:1, id:3 ... [1]
00 00 00 05 01 00 00 00 03 | .........
#12200 1438942500.00000 _get_msg: waiting for message... [1]
#12200 1438942500.00000 _do_io: _do_io connected: 1
#12200 1438942500.00000 _do_io: _do_io select(-,-,-, undef)
#12200 1438942500.00000 _do_io: _do_io write queue: 9, syswrite: 9, max: 65536, $!:
00 00 00 05 01 00 00 00 03 | .........
#12200 1438942500.00000 _do_io: _do_io select(-,-,-, undef)
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
#12200 1438942502.00000 _do_io: _do_io read sysread: 0, total read: 0, $!:
#12200 1438942502.00000 _conn_lost: _conn_lost
#12200 1438942502.00000 _set_status: _set_status code: 7, str: Connection lost
#12200 1438942502.00000 _set_error: _set_err code: 37, str: Connection to remote server is broken
#12200 1438942502.00000 _conn_lost: _conn_lost
#12200 1438942502.00000 disconnect: Net::SFTP::Foreign=HASH(0xee3d50)->disconnect called (ssh pid: 12201)
#12200 1438942502.00000 _conn_lost: _conn_lost
#12200 1438942502.00000 disconnect: starting dirty cleanup of process 12201
#12200 1438942502.00000 disconnect: killing process 12201 with signal 0
#12200 1438942502.00000 disconnect: waitpid returned 12201
#12200 1438942502.00000 disconnect: process 12201 reaped
#12200 1438942502.00000 DESTROY: Net::SFTP::Foreign=HASH(0xee3d50)->DESTROY called (current pid: 12200, disconnect_by_pid: )
#12200 1438942502.00000 disconnect: Net::SFTP::Foreign=HASH(0xee3d50)->disconnect called (ssh pid: )
#12200 1438942502.00000 _conn_lost: _conn_lost

I'm using IO::Pty v 1.12 and Net::SFTP::Foreign 1.77, can anybody help me?

This is your problem:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

Your login isn't being accepted. Can't tell you why, because it's a server side error. Diagnostic steps might include: running sftp by hand, and verifying that the username/password can in fact, log in to the sftp server and run an 'ls'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM