我正在使用Net :: OpenSSH连接到远程服务器。
my $ssh = Net::OpenSSH->new(
$server,
user => $user_name,
passwd => $password,
strict_mode => 0,
master_opts => ['-v']
);
当身份验证失败/指定了错误的密码时,它会挂起。
OpenSSH_6.0p1, OpenSSL 0.9.8d 28 Sep 2006
debug1: Reading configuration data /usr/software/etc/ssh_config
debug1: Connecting to 10.53.34.200 [10.53.34.200] port 22.
debug1: Connection established.
...
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: password
它挂在上面一行。
设置“$ Net :: OpenSSH :: debug = -1;”返回:
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: password
# file object not yet found at /usr/hema/.libnet-openssh-perl/diag-10.53.34.200-21463-907722
# file object not yet found at /usr/hema/.libnet-openssh-perl/diag-10.53.34.200-21463-907722
如何在这种情况下退出?
答案 0 :(得分:1)
从模块文档中可以看出处理错误的方法:
my $ssh = Net::OpenSSH->new($host);
$ssh->error and
die "Couldn't establish SSH connection: ". $ssh->error;