设置SSH连接超时

编程入门 行业动态 更新时间:2024-10-28 09:26:27
本文介绍了设置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连接超时

本文发布于:2023-10-16 06:15:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1496733.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:SSH

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!