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?
Thanks
Use the ssh_timeout command to set the number of minutes that the SSH session can be idle before it is closed. The default timeout interval is 0 minutes. Use this value, if you do not want the SSH session to expire. The minimum timeout interval is 2 minutes.
Login to the client machine and open the /etc/ssh/ssh_config file to set the necessary parameter values to increase the SS connection timeout. ServerAliveInterval and ServerAliveCountMax parameters are set to increase the connection timeout. These parameters work similarly to the server-side configuration parameters.
The most common ones are: Connecting to a wrong/outdated IP/host. Connecting to the wrong SSH port. Firewall blocking the connection.
if you call ssh script you can use something like that
ssh -o ConnectTimeout=10 <hostName>
where 10 is the number of seconds
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With