How to disable SSH timeout

By default, most SSH servers are set to disconnect clients who has been inactive or idle after a certain period of time. You'll be prompted with message similar to the following upon disconnection;

Read from remote host oseems.com: Connection reset by peer
Connection to oseems.com closed.

To avoid being disconnected, you have the choice to either configure your SSH client, or the server itself if you have the required permission.

SSH Client

This method is the way to go if you have no administrator access to the server you are connecting to. This method will apply to all the servers you are connecting to, instead of only to a specific server.

What you're basically to do is to configure your SSH client client to periodically send keep alive message to the SSH server. If you're running Ubuntu / Debian, edit /etc/ssh/ssh_config and set ServerAliveInterval option to the following;

ServerAliveInterval 100

This option is to tell your SSH client to automatically send the keep alive message every 100 seconds to the SSH server, even if you're away from your client machine. The server will assume you're not idling and will not disconnect your session.

SSH server

If you have administrator access to the server, you can configure the ClientAliveIntervalTCPKeepAlive and ClientAliveCountMax options in the SSHd configuration file. If you're running Ubuntu / Debian, the file's path is /etc/ssh/sshd_config

ClientAliveInterval 30
TCPKeepAlive yes 
ClientAliveCountMax 99999

You will need to restart the SSH server for the changes to take effect.

sudo /etc/init.d/sshd restart
转自:http://docs.oseems.com/general/application/ssh/disable-timeout
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值