bash 如何减少 ssh 连接超时值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18389367/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to decrease ssh connection timeout value
提问by JavaRed
I have a list of full remote host ip addresses. I wrote a script to connect all the hosts in this list, one by one. My question is, sometimes when an IP address is down, script waits for a while (maybe a couple of minute) to go and execute next host. So I would like to decrease this waiting time. For example after 10 s, I want ssh connection is timeout and my script tries the next IP address. So how I can tweak this?
我有一个完整的远程主机 IP 地址列表。我写了一个脚本,将这个列表中的所有主机,一一连接起来。我的问题是,有时当 IP 地址关闭时,脚本会等待一段时间(可能几分钟)去执行下一个主机。所以我想减少这个等待时间。例如,在 10 秒后,我希望 ssh 连接超时并且我的脚本尝试下一个 IP 地址。那么我该如何调整呢?
Thanks
谢谢
回答by rderoldan1
if you call ssh script you can use something like that
如果你调用 ssh 脚本,你可以使用类似的东西
ssh -o ConnectTimeout=10 <hostName>
where 10 is the number of seconds
其中 10 是秒数
回答by iamauser
You can learn much more by typing man ssh
for OpenSSH
command line options and man sshd
for OpenSSH
daemon options...
您可以通过键入学到更多man ssh
的OpenSSH
命令行选项,并man sshd
为OpenSSH
守护进程选项...