如何设置ssh超时? [英] How to set ssh timeout?

查看:54
本文介绍了如何设置ssh超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在远程主机上执行通过无密码 SSH 连接的脚本.我想设置一个超时,这样如果远程主机需要无限长的时间来运行,我想退出那个 ssh 会话并继续我的 sh 脚本中的其他行.

I'm executing a script connecting via password-less SSH on a remote host. I want to set a timeout, so that if the remote host is taking an infinite time to run, I want to come out of that ssh session and continue other lines in my sh script.

如何设置超时时间?

推荐答案

ssh -o ConnectTimeout=10  <hostName>

其中 10 是以秒为单位的时间.此超时仅适用于连接的创建.

Where 10 is time in seconds. This Timeout applies only to the creation of the connection.

这篇关于如何设置ssh超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆