Fixing “Write failed: Broken pipe” on Yosemite

After latest update to my macbook pro I noticed that my SSH connections started dropping if I kept them idle for few minutes. Each time the session terminated with the text “Write failed: Broken pipe”. I have observed that the connection used to hang for a long while before this error message was shown.

This was not the behavior before so I suspected that recent updates might have changed some configuration and hence I started looking around. I found an article which explained how to configure my Macbook.

Based on the inputs provided in the article I edited the file /etc/ssh_config using the following command:
sudo vi /etc/ssh_config

And changed/uncommented the following lines:
Host *
ServerAliveInterval 60
TCPKeepAlive yes

I learnt another point in this article that during the SSH session if I press “~” followed by “.” then the connection terminates immediately. If it doesn’t then pressing enter before doing this helps.

Leave a Reply

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