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 c
try this:
timeout 5 ssh user@ip
timeout executes the ssh command (with args) and sends a SIGTERM if ssh doesn't return after 5 second. for more details about timeout, read this document: http://man7.org/linux/man-pages/man1/timeout.1.html
or you can use the param of ssh:
ssh -o ConnectTimeout=3 user@ip