1. 问题
几分钟不操作,就退了ssh:
packet_write_wait: Connection to 192.168.21.212 port 22: Broken pipe
2. 解决
方法一:客户端操作
-
切换root身份:
sudo su -
进入 ~/.ssh 目录下新建一个config文件:
vim config -
在config中添加配置:
Host * ServerAliveInterval 60 ServerAliveCountMax 10000
方法二:服务端操作
如果客户端有很多,不想在每个客户端进行设置,可以在服务器的 /etc/ssh/sshd_config下进行设置:
- 进入root身份:
sudo su
root身份下编辑sshd_config文件:/etc/ssh/sshd_config
-
添加配置:
ClientAliveInterval 60 ClientAliveCountMax 10000
分别是 等待连接的时间和最大连接次数。
注意:尽量在ssh客户端改,在服务端改不安全
结果
- 单独设置服务端:会断开
- 客户端和服务端都设置:还是会断开!无语

参考:
4721



被折叠的 条评论
为什么被折叠?



