Operating System - HP-UX
1834249 Members
2267 Online
110066 Solutions
New Discussion

Re: Test SSH connectivity

 
SOLVED
Go to solution
Coolmar
Esteemed Contributor

Test SSH connectivity

Hi,

We have many servers here and I wrote a script to test for ssh connectivity between all the servers - faster than waiting for the firewall to go through their rules. Anyway, basically it just tries to ssh to a server and if there is a connection it echos it to the screen..the problem is that if there is not a connection it waits for the "connection timeout" to finally come back and echo "no connection". Is there a way to shorten that timeout...or add to the script that if there is not connection after 3 seconds, then echo "no connection"?

Thanks
3 REPLIES 3
Joel Girot
Trusted Contributor
Solution

Re: Test SSH connectivity

Hi Sally

The -o ConnectTimeout=3 option of the ssh command shorten the timeout :

$ ssh joel@192.168.1.204 -o ConnectTimeout=3
ssh: connect to host 192.168.55.204 port 22: Connection timed out

(after 3 seconds)

Have a nice day !

Joel
spex
Honored Contributor

Re: Test SSH connectivity

Sally,

You can also add 'ConnectTimeout=3' to your ssh config file. System-wide ssh config is in /opt/ssh/etc/ssh_config.

PCS
Coolmar
Esteemed Contributor

Re: Test SSH connectivity

see above