ssh登陆报错:packet_write_wait: Connection to x.x.x.x port 22: Broken pipe
Posted chentianwei
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ssh登陆报错:packet_write_wait: Connection to x.x.x.x port 22: Broken pipe相关的知识,希望对你有一定的参考价值。
ssh登陆报错:packet_write_wait: Connection to x.x.x.x port 22: Broken pipe
参考文章:
https://patrickmn.com/aside/how-to-keep-alive-ssh-sessions/
用 ssh 命令连接服务器之后,如果一段时间不操作,再次进入 Terminal 时会有一段时间没有响应,然后就出现错误提示:
packet_write_wait: Connection to 47.92.226.106 port 22: Broken pipe
只能重新用 ssh 命令进行连接。
Solution:
1.如果有多台服务器,不想在每台上设置,只需在客户端设置即可:
- 全部都保持连接:(root access required), edit
/etc/ssh/ssh_config
- 只在你的user上设置:edit
~/.ssh/config
(create the file if it doesn’t exist)
Host *
ServerAliveInterval 300
ServerAliveCountMax 2
2. 如果有多台个人管理服务器,可以在服务器端配置:
make your OpenSSH server keep alive all connections with clients by adding the following to /etc/ssh/sshd_config
:
ClientAliveInterval 300 ClientAliveCountMax 2
这些设置让ssh client or server发送一个空包到另一端,每5分钟一次。
如果它在尝试了2次后,仍没有收到任何响应,则放弃。即连接被断开了。
通过man ssu_config可以看到详细说明:
SYNOPSIS ~/.ssh/config /etc/ssh/ssh_config DESCRIPTION ssh(1) obtains configuration data from the following sources in the following order: 1. command-line options 2. user‘s configuration file (~/.ssh/config) 3. system-wide configuration file (/etc/ssh/ssh_config)
以上是关于ssh登陆报错:packet_write_wait: Connection to x.x.x.x port 22: Broken pipe的主要内容,如果未能解决你的问题,请参考以下文章
容器下载的是centos8的镜像,scp出现packet_write_wait: Connection to **** port 22: Broken pipe 问题解决
ssh登陆概率性失败,报错:kex_exchange_identification
ssh登陆概率性失败,报错:kex_exchange_identification
使用git往github上提交代码时出现[packet_write_wait connection to xx.xx.xx.xx Broken pipe]错误的解决办法