linux ssh不超时时间设置,ssh 设置超时时间

NAT firewalls like to time out idle sessions to keep their state

tables clean and their memory footprint low.

NAT防火墙喜欢对空闲的会话进行超时处理,以确保它们状态表的干净和内存的低占用率。

Some firewalls are nice, and let you idle for up to a day or so;

some are gestapo and terminate your session after 5

minutes.

一些防火墙比较友好,允许你的空闲会话时间为一天甚至超过一天;另一些却如盖世太保,5分钟空闲就终止你的会话。

I finally got tired of my ssh sessions getting disconnected at

places where I don't control the firewalls, and figured out how to

stop it.

我最终疲于我的ssh连接会话被我不能控制的防火墙断开,并找出了阻止它的方案。

Turn out ssh has a nice inband keepalive mechanism, and even

lets you set it on a per-destination basis.

结论是ssh内带有一个很好的保持会话存活机制,甚至允许你在每一台目标机器上设置。

Just create a ~/.ssh/config file with something like the

following (* will match any host, if you wanted you could restrict

this to particular destinations like *kehlet.cx):

只要用以下类似的内容创建一个

~/.ssh/config文件(*号将匹配所有的主机,如果你想,你可以严格的设置它为特定的目标主机,像kehlet.cx):

----------------

Host *

ServerAliveInterval 240

----------------

That's how often, in seconds, ssh will send a keepalive request

(at the application layer) to the other end if the connection's

been otherwise idle. 4 minutes should be good

:-).

这通常是以秒为单位,如果这个连接空闲,ssh将发送一个保持存活的请求(在应用层)给另一端。4分钟应该不错。

The Host line lets you pattern match your destinations. Minimal

effort, no impact to your system (say, as you would have if you

mucked with your system's default TCP keepalive settings), and it

works like a charm.

Host行使你匹配你的目标主机。极小的努力,对你的系统毫无影响(即,如果你弄乱你的系统默认TCP保持存活时间设置的话,将影响你的系统),并且很有效。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值