这是基于another question that was asked但尚未完全回答。
我遇到与user2621980相同的行为。我的错误
could not connect pty as controlling terminal!
当我用truss运行脚本时,消失了。
另外,请务必注意,当我在Server_A上运行脚本时,它可以正常工作。但是当Server_B上的另一个脚本调用(通过ssh调用)Server_A上的脚本时,就会发生错误。
我想知道salva是否能够重现这一点和/或是否已确定永久性解决方案。
关于我的环境的一些细节:
以下是我使用的代码片段:
#!/usr/local/bin/perl
use Net::SFTP::Foreign;
use IO::Pty;
use POSIX;
## Enable debugging
$Net::SFTP::Foreign::debug = -1;
## Instantiate the variables
my ($action,$host,$user,$pass,$file,$ldir,$rdir) = @ARGV;
## Create the SFTP connection
my $sftp = Net::SFTP::Foreign->new(host => $host,
user => $user,
password => $pass);
$sftp->die_on_error("Unable to establish SFTP connection");
以下是调试的输出:
#15593 1400766701.00000 new: This is Net::SFTP::Foreign 1.77
#15593 1400766701.00000 new: Loaded from /export/home/hccprod/lib/Net/SFTP/Foreign.pm
#15593 1400766701.00000 new: Running on Perl v5.18.1 for solaris
#15593 1400766701.00000 new: debug set to -1
#15593 1400766701.00000 new: ~0 is 4294967295
#15593 1400766701.00000 new: Using backend Net::SFTP::Foreign::Backend::Unix 1.76_03
#15593 1400766701.00000 _init_transport: ssh cmd: ssh -o NumberOfPasswordPrompts=1 -o PreferredAuthentications=keyboard-interactive,password -l myusername my.ftp.server -s sftp
Error: could not connect pty as controlling terminal!
#15593 1400766701.00000 _init_transport: starting password authentication
#15593 1400766701.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766702.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766703.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766704.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766705.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766706.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766707.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766708.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766709.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766710.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766711.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766712.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766713.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766714.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766715.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766716.00000 _init_transport: waiting for data from the pty to become available
#15593 1400766717.00000 _init_transport: waiting for data from the pty to become available
Permission denied (publickey,password,keyboard-interactive).
#15593 1400766718.00000 _conn_lost: _conn_lost
#15593 1400766718.00000 _set_status: _set_status code: 6, str: No connection
#15593 1400766718.00000 _set_error: _set_err code: 37, str: SSH slave exited unexpectedly with error code 255
Unable to establish SFTP connection: SSH slave exited unexpectedly with error code 255 at /export/home/username/bin/sftp_service_debug.pl line 31.
#15593 1400766718.00000 DESTROY: Net::SFTP::Foreign=HASH(0x17cc20)->DESTROY called (current pid: 15593, disconnect_by_pid: )
#15593 1400766718.00000 disconnect: Net::SFTP::Foreign=HASH(0x17cc20)->disconnect called (ssh pid: )
#15593 1400766718.00000 _conn_lost: _conn_lost
以下是打开警告的调试输出:
Unquoted string "vars" may clash with future reserved word at ./test_sftp.pl line 2.
"my" variable $cmd masks earlier declaration in same scope at ./test_sftp.pl line 24.
"my" variable $result masks earlier declaration in same scope at ./test_sftp.pl line 26.
* Calling remote script:
ssh centralftp "sftp_service_debug.pl 'put' 'host' 'username' 'password' 'file' 'srcdir' 'destdir'"
#7284 1402514985.00000 new: This is Net::SFTP::Foreign 1.77
#7284 1402514985.00000 new: Loaded from /export/home/hccprod/lib/Net/SFTP/Foreign.pm
#7284 1402514985.00000 new: Running on Perl v5.18.1 for solaris
#7284 1402514985.00000 new: debug set to -1
#7284 1402514985.00000 new: ~0 is 4294967295
#7284 1402514985.00000 new: Using backend Net::SFTP::Foreign::Backend::Unix 1.76_03
#7284 1402514985.00000 _init_transport: ssh cmd: ssh -o NumberOfPasswordPrompts=1 -o PreferredAuthentications=keyboard-interactive,password -l onyximport centralftp.pegs.com -s sftp
warning: TIOCSCTTY failed, slave might not be set as controlling terminal: Inappropriate ioctl for device at /export/home/hccprod/lib/IO/Pty.pm line 121.
Error: could not connect pty as controlling terminal!
#7284 1402514985.00000 _init_transport: starting password authentication
#7284 1402514985.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514986.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514987.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514988.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514989.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514990.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514991.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514992.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514993.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514994.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514995.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514996.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514997.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514998.00000 _init_transport: waiting for data from the pty to become available
#7284 1402514999.00000 _init_transport: waiting for data from the pty to become available
#7284 1402515000.00000 _init_transport: waiting for data from the pty to become available
#7284 1402515001.00000 _init_transport: waiting for data from the pty to become available
Permission denied (publickey,password,keyboard-interactive).
#7284 1402515002.00000 _conn_lost: _conn_lost
#7284 1402515002.00000 _set_status: _set_status code: 6, str: No connection
#7284 1402515002.00000 _set_error: _set_err code: 37, str: SSH slave exited unexpectedly with error code 255
Unable to establish SFTP connection: SSH slave exited unexpectedly with error code 255 at /export/home/hccprod/bin/sftp_service_debug.pl line 40.
#7284 1402515002.00000 DESTROY: Net::SFTP::Foreign=HASH(0x17cc20)->DESTROY called (current pid: 7284, disconnect_by_pid: )
#7284 1402515002.00000 disconnect: Net::SFTP::Foreign=HASH(0x17cc20)->disconnect called (ssh pid: )
#7284 1402515002.00000 _conn_lost: _conn_lost
答案 0 :(得分:0)
使用某个操作系统跟踪实用程序truss
在Server_A上运行脚本,并发布工作和失败(通过Server_B运行)的输出。
如果您不想公开发布,可以通过电子邮件将截图发送给我。
作为一种解决方法,您可以尝试从Net :: OpenSSH调用Net :: SFTP :: Foreign,但您必须安装真正的OpenSSH客户端。
my $ssh = Net::OpenSSH->new($host);
my $sftp = $ssh->sftp;
两个模块的密码处理代码相似但不完全相同。