Why am I getting packet_write_wait: Connection to xxx.xx.xx.xxx port 22: Broken pipe?

September 1, 2017 1.8k views
Linux Commands Ubuntu 16.04

Earlier I was able to ssh to my droplet using ssh root@xxx.xx.xx.xxx command. But from yesterday I am getting this error packet_write_wait: Connection to xxx.xx.xx.xxx port 22: Broken pipe. What could be the possible reason for it. And how to solve it?

2 Answers

Hi, if you're getting that error it means that your SSH connection was cut off due to a long period of inactivity. You can prevent that from happening by configuring either the SSH server or client to check if the other is still connected periodically.

To do so on the server, add the following two lines to /etc/ssh/sshd_config:

ClientAliveInterval 300
ClientAliveCountMax 2

On the client side, if you are using the ssh command line program, add the following lines to ~/.ssh/config. This will enable this feature for all remote hosts.

Host *
    ServerAliveInterval 300
    ServerAliveCountMax 2

Otherwise, if you're using a GUI program, it should have a setting for Keep Alive.

This will send a ping every 300 seconds (5 minutes) and disconnect after 2 failures (in case the other side actually disconnected and isn't simply inactive).

I ran into the problem of similar nature. I found out the problem to be sftp configuration of the server. I tried to add users with sftp access but not the ssh. Later found out that the "Match Group groupname" record in /etc/ssh/sshdconfig had some issues. My normal account was also mixed up in the ssh client list that produced 'packetwrite_wait' issue.

Now, I removed my normal user from the group and everything is working fine.

It might not be the same over your case but do keep in mind if your normal user (the one you try to login with ssh) is not on the groups that has limited access on the server.

This might have been solved. If above solution doesn't work for you, try checking group and access records on your server.

Have another answer? Share your knowledge.