how to increase Linux ssh connection timeout

本文介绍了如何在Linux中增加SSH连接超时的方法。通过在客户端的~/.ssh/ssh_config文件中添加ServerAliveInterval 20和ServerAliveCountMax 100,或者在命令行中使用相应选项,可以保持SSH连接活跃。此外,服务器端可以通过设置TMOUT变量(例如TMOUT=600,即10分钟)来延长SSH会话的存活时间。如果需要更长的超时,可以调整TMOUT的值。这些步骤有助于避免SSH连接因无活动而断开。

Recommended Steps to increase SSH connection timeout

We can use the following way to increase the SSH connection timeout in Linux.

  • add ServerAliveInterval 20 and ServerAliveCountMax 100 on
    client-side in file ~/.ssh/ssh_config or we can add them to
    command line like this $ ssh -o ServerAliveInterval=20 -o
    ServerAliveCountMax=100 user@example.com
  • change TMOUT variable on server-side with the following command.

Commands to change TMOUT value on server side

  • TMOUT=600 ( this is 10 minutes).
  • export TMOUT
  • echo $TMOUT

This will keep the SSH connection alive for 10 minutes. We can change TMOUT value for a longer SSH connection timeout value if needed.
Related:

Increase Linux SSH Connection Timeout Quick Guide
Recommended Steps to increase SSH connection timeout

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值