我有一个使用lftp连接到服务器并下载文件的自动脚本。 我已经有脚本成功运行了好几次(所以我知道在理论上是有效的)。 最近,我怀疑我们有问题连接到远程服务器(我们不拥有它,所以我不能validation它是“上”还是“下”)。
我知道lftp通过SSH连接。 当我运行lftp程序时,它只是不断尝试重新连接。
/bin/lftp -d -e 'set sftp:connect-program "ssh -a -x -i /home/username/.ssh/id_rsa -o "ConnectionAttempts=1" -o "ConnectTimeout=10" -o "BatchMode=yes" -o "ServerAliveInterval=15""; set cmd:fail-exit on; set dns:max-retries 3; set dns:fatal-timeout 20; set net:max-retries 3; set net:timeout 25; set ssl:key-file /home/username/.ssh/id_rsa; set xfer:clobber on; get OUT/remote_filename.txt -o remote_filename.txt; bye' -uremoteusername,xyz sftp://sftp.remoteserver.com ---- Running connect program (ssh -a -x -i /home/username/.ssh/id_rsa -o ConnectionAttempts=1 -o ConnectTimeout=10 -o BatchMode=yes -o ServerAliveInterval=15 -s -l remoteusername sftp.remoteserver.com sftp) ---> sending a packet, length=5, type=1(INIT), id=0 <--- Connection timed out during banner exchange **** Peer closed connection ---- Disconnecting ---- Running connect program (ssh -a -x -i /home/username/.ssh/id_rsa -o ConnectionAttempts=1 -o ConnectTimeout=10 -o BatchMode=yes -o ServerAliveInterval=15 -s -l remoteusername sftp.remoteserver.com sftp) ---> sending a packet, length=5, type=1(INIT), id=0 <--- Connection timed out during banner exchange **** Peer closed connection ---- Disconnecting ---- Running connect program (ssh -a -x -i /home/username/.ssh/id_rsa -o ConnectionAttempts=1 -o ConnectTimeout=10 -o BatchMode=yes -o ServerAliveInterval=15 -s -l remoteusername sftp.remoteserver.com sftp) ---> sending a packet, length=5, type=1(INIT), id=0 <--- Connection timed out during banner exchange **** Peer closed connection ---- Disconnecting ---- Running connect program (ssh -a -x -i /home/username/.ssh/id_rsa -o ConnectionAttempts=1 -o ConnectTimeout=10 -o BatchMode=yes -o ServerAliveInterval=15 -s -l remoteusername sftp.remoteserver.com sftp) ---> sending a packet, length=5, type=1(INIT), id=0 <--- Connection timed out during banner exchange **** Peer closed connection ---- Disconnecting ---- Running connect program (ssh -a -x -i /home/username/.ssh/id_rsa -o ConnectionAttempts=1 -o ConnectTimeout=10 -o BatchMode=yes -o ServerAliveInterval=15 -s -l remoteusername sftp.remoteserver.com sftp) ---> sending a packet, length=5, type=1(INIT), id=0 <--- Connection timed out during banner exchange **** Peer closed connection ---- Disconnecting ---- Running connect program (ssh -a -x -i /home/username/.ssh/id_rsa -o ConnectionAttempts=1 -o ConnectTimeout=10 -o BatchMode=yes -o ServerAliveInterval=15 -s -l remoteusername sftp.remoteserver.com sftp) ---> sending a packet, length=5, type=1(INIT), id=0 <--- Connection timed out during banner exchange **** Peer closed connection ---- Disconnecting Interrupt
你可以看到它试图重新连接至less6次,我手动杀死它。 它似乎忽略了3的最大重试次数。
如果我手动testing底层的SSH连接,这似乎是失败(1尝试后):
ssh -v -v -v -a -x -i /home/username/.ssh/id_rsa -o ConnectionAttempts=1 -o ConnectTimeout=10 -o BatchMode=yes -o ServerAliveInterval=15 -s -l remoteusername sftp.remoteserver.com sftp OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 60: Applying options for * debug1: Executing proxy command: exec /usr/bin/sss_ssh_knownhostsproxy -p 22 sftp.remoteserver.com debug3: timeout: 10000 ms remain after connect debug1: permanently_drop_suid: 1839400042 debug3: Incorrect RSA1 identifier debug3: Could not load "/home/username/.ssh/id_rsa" as a RSA1 public key debug1: identity file /home/username/.ssh/id_rsa type 1 debug1: identity file /home/username/.ssh/id_rsa-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.6.1 Connection timed out during banner exchange
所以,这个问题看起来像在ssh中的初始设置。 它看起来像lftp没有意识到ssh失败,所以它不断试图build立连接。
有没有办法让这两个玩好? 我想避免我的脚本永远挂起,因为它试图build立连接。
谢谢!