SSH Timeout code example

Example 1: increase ssh session timeout linux

ssh -o ServerAliveInterval=60 -i Firstme.pem [email protected]

Example 2: increase ssh timeout

#Add these lines on sshd_config

ClientAliveInterval 120
ClientAliveCountMax 720

Example 3: ssh connection timeout

$ sudo vi /etc/ssh/sshd_config # in server

#Add the following
ClientAliveInterval  1200
ClientAliveCountMax 3

$ sudo systemctl reload sshd
# Remember timeout value in seconds = ClientAliveInterval * ClientAliveCountMax

Example 4: ssh timeout option

ssh -o ConnectTimeout=30  <hostName>		# 30 seconds

Example 5: ssh connection timeout

ClientAliveInterval  1200
ClientAliveCountMax 3

Example 6: ssh connection timeout

$ sudo vi /etc/ssh/sshd_config