码迷,mamicode.com
首页 > 其他好文 > 详细

ssh登陆报错:packet_write_wait: Connection to x.x.x.x port 22: Broken pipe

时间:2018-10-28 17:59:41      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:data   pip   interval   psi   客户   inter   terminal   The   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.   users 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

标签:data   pip   interval   psi   客户   inter   terminal   The   pipe   

原文地址:https://www.cnblogs.com/chentianwei/p/9866046.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!