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)

 

转载于:https://www.cnblogs.com/chentianwei/p/9866046.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值