Mac terminal 连接ssh 显示 broken pipe

用Mac terminal 连接ssh后,如果一段时间没有操作,terminal会显示”broken pipe”,需要重新登录.在~/.ssh/文件夹中添加config文件,并进行如下修改即可:

ServerAliveInterval 5
TCPKeepAlive no

ServerAliveInterval 5让terminal每5秒钟自动和远程的sshd进行一次握手,避免被踢掉;
TCPKeepAlive设置为no是为了避免临时的网络问题导致ssh断开,也能避免ssh断开导致的terminal假死状态.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>