Net :: SFTP ::外部密码身份验证错误

时间:2015-08-07 11:03:36

标签: perl sftp

我正在运行以下脚本来连接到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";
}

但是,在密码更改期间它有点失败,这是调试日志:

#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

我正在使用IO :: Pty v 1.12和Net :: SFTP :: Foreign 1.77,有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:3)

这是你的问题:

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

您的登录信息未被接受。无法告诉您原因,因为它是服务器端错误。诊断步骤可能包括:手动运行sftp,并验证用户名/密码实际上可以登录到sftp服务器并运行“&#39;”。