[小诀窍分享]如何保持ssh链接不断

由于本人有两台笔记本电脑,需要使用 ssh 链接另外一台笔记本,但是 ssh 在不使用一段时间以后会自动断开。如何保持 ssh 不断呢?以下是我在网上找到的解决办法。我使用了第一种办法,亲测有用!
tonychiu.blog.51cto.com/656605/522304/
有需要的童鞋可以保留下来啊!!

说到会话超时,最近 man bash 时看到一个环境变量很有意思,下面是 man 里的描述
TMOUT If set to a value greater than zero, TMOUT is treated as the
default timeout for the read builtin. The select command termi-
nates if input does not arrive after TMOUT seconds when input is
coming from a terminal. In an interactive shell, the value is
interpreted as the number of seconds to wait for a line of input
after issuing the primary prompt. Bash terminates after waiting
for that number of seconds if a complete line of input does not
arrive.
也就是说设定一个值(比如 30)后,若 30 秒内没有动作就会自动退出当前的 session。似乎与 ssh 的 timeout 有异曲同工之妙。

不太一样,SSH 是 TCP KeepAlive 长连接超时断掉,Bash 那个应该是主动断开连接

推荐用 tmux,ssh 断了也不怕。

个人推荐使用 mosh