![笔记本电脑上通过 WiFi 进行的 SSH 突然停止](https://linux22.com/image/943876/%E7%AC%94%E8%AE%B0%E6%9C%AC%E7%94%B5%E8%84%91%E4%B8%8A%E9%80%9A%E8%BF%87%20WiFi%20%E8%BF%9B%E8%A1%8C%E7%9A%84%20SSH%20%E7%AA%81%E7%84%B6%E5%81%9C%E6%AD%A2.png)
我有一台运行 Ubuntu 服务器和 Plex 的笔记本电脑(服务器运行在 WiFi(2.4 GHz)上)。当通过 ssh 进入服务器时,它通常可以正常工作,但随机地(例如 40 分钟后)它会显示主机关闭,尽管笔记本电脑仍在运行,我必须重新启动服务器才能再次使用 ssh。
*编辑-我注意到一种模式,这通常发生在我通过键入 exit 断开 ssh 连接时,10 分钟或更长时间后它显示主机关闭……等等,我能做的唯一解决方案是运行 htop 或任何其他命令来阻止它断开连接。
onlysaikihere@hub: $ client_loop: ssh_packet_write_poll: Connection to 192.168.0.145 port 22: Host is down
sahishnukumar@Sahishnu-kumar ~ % ssh onlysaikihere0192.168.0.145
ssh: connect to host 192.168.0.145 port 22: Host is down
sahishnukumar@Sahishnu-kumar ~ % ssh [email protected]
ssh: connect to host 192.168.0.145 port 22: Host is down
sahishnukumar@Sahishnu-kumar ~ % ssh onlysaikihere0192.168.0.145
ATTA
AC
sahishnukumar@Sahishnu-kumar
~ % ssh [email protected]
使用 mosh 给出以下输出
sahishnukumar@Sahishnu-kumar ~ % mosh [email protected]
/opt/homebrew/bin/mosh: Could not connect to 192.168.0.145, last tried 192.168.0.145: Host is down
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
/opt/homebrew/bin/mosh: Did not find remote IP address (is SSH ProxyCommand disabled?).
sahishnukumar@Sahishnu-kumar ~ %
plex 服务器也停止工作
格式化笔记本电脑并修复问题
答案1
尝试设置 SSH 以进行常规 ping:
Host *
ServerAliveInterval 60
将此添加到您的顶部~/.ssh/config
,会话就不会再丢失。默认的较大间隔不会阻止这种情况发生。