Ssh – Can we make ssh time out while waiting for a password

sshtimeout

I have written a script that is expected to get a bunch of host names from some place and run a command on each of those hosts:

ssh "$host" some command

I have the necessary configuration to make ssh connections without the need for a password. However, sometimes we encounter a host that does need a password and the script hangs.

Is there a way to make ssh time out while waiting for a password? I don't want to use the timeout command.

Best Answer

You are looking for LoginGraceTime in your sshd_config.

From sshd_config(5):

LoginGraceTime
             The server disconnects after this time if the user has not successfully logged in.  If the value is 0, there is no time
             limit.  The default is 120 seconds.
Related Question