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