SSH “timed out waiting for input: auto-logout”

For a secured Linux system, normally there will be auto logout configured for SSH. It means if your SSH session has no activities for some time configured, the session will be disconnected. It’s a problem if you need to run some kind of interative long-running progams because such programs need some imputs in the middle and you cannot run them at the background.

For some SSH clients like putty you can try to set up “sending null packets to keep session active“, but that might not work all the time. If you have the root privilege, you can disable this behaviour temporarily. For Linux Bash, usually the environment variable TMOUT is set either at the user level (.bashrc or .bash_profile) or at the system level (/etc/profile) to implement this security measure.

This variable defines in how many seconds without any activities, your SHELL session will be closed automatically.

So set this variable accordingly, for example:

  1. Time out after 1 hour
  2. No time out

One thing to note, as a system wide setting, a shell script is recommended under /etc/profile.d, for example:

$ cat /etc/profile.d/
export TMOUT
readonly TMOUT

Also check sshd_config (/etc/ssh/sshd_config), there are two settings related to SSH client time out.

Sets the number of client alive messages which may be sent without sshd(8) receiving any messages back from the client. If this threshold is reached while client alive messages are being sent, sshd will disconnect the client, terminating the session. It is important to note that the use of client alive messages is very different from TCPKeepAlive. The client alive messages are sent through the encrypted channel and therefore will not be spoofable. The TCP keepalive option enabled by TCPKeepAlive is spoofable. The client alive mechanism is valuable when the client or server depend on knowing when a connection has become unresponsive.
The default value is 3. If ClientAliveInterval is set to 15, and ClientAliveCountMax is left at the default, unresponsive SSH clients will be disconnected after approximately 45 seconds. Setting a zero ClientAliveCountMax disables connection termination.

Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s