设置SSH连接超时 [英] Set SSH connection timeout
本文介绍了设置SSH连接超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试缩短ssh尝试打开到主机的连接的时间。例如,如果我设置ssh www.google.com
,则需要很长时间才能返回提示符。
我读到关于改用ssh -o ConnectTimeout=10 www.google.com
的报道,但即使这样也需要很长时间。是否可以修改一些尝试以减少阻止时间?
SSH
问题可能是推荐答案正在尝试连接所有www.google.com
解析到的不同IP。例如在我的机器上:
# ssh -v -o ConnectTimeout=1 -o ConnectionAttempts=1 www.google.com
OpenSSH_5.9p1, OpenSSL 0.9.8t 18 Jan 2012
debug1: Connecting to www.google.com [173.194.43.20] port 22.
debug1: connect to address 173.194.43.20 port 22: Connection timed out
debug1: Connecting to www.google.com [173.194.43.19] port 22.
debug1: connect to address 173.194.43.19 port 22: Connection timed out
debug1: Connecting to www.google.com [173.194.43.18] port 22.
debug1: connect to address 173.194.43.18 port 22: Connection timed out
debug1: Connecting to www.google.com [173.194.43.17] port 22.
debug1: connect to address 173.194.43.17 port 22: Connection timed out
debug1: Connecting to www.google.com [173.194.43.16] port 22.
debug1: connect to address 173.194.43.16 port 22: Connection timed out
ssh: connect to host www.google.com port 22: Connection timed out
如果我使用特定的IP运行它,它返回的速度要快得多。
编辑:我已经计时(用time
),结果是:
- www.google.com-5.086秒
- 173.94.43.16-1.054秒
这篇关于设置SSH连接超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文