SSH logon error: packet_write_wait: connection to x. x port 22: broken pipe
References:
Https://patrickmn.com/aside/how-to-keep-alive-ssh-sessions/
After you connect to the server by using an SSH command, if you do not perform the operation for a period of time, when you enter terminal again, there will be no response for a period of time, and an error prompt will appear:
packet_write_wait: Connection to 47.92.226.106 port 22: Broken pipe
You can only use the SSH command to connect again.
Solution:
1. If you have multiple servers and do not want to set them on each server, you only need to set them on the client:
- Keep all connections: (root access required), Edit
/etc/ssh/ssh_config
- Set: edit on your user only
~/.ssh/config
(Create the file if it doesn't exist)
Host *
ServerAliveInterval 300
ServerAliveCountMax 2
2. If there are multiple personal management servers, you can configure them on the server side:
Make your OpenSSH server keep alive all connections with clients by adding the following/etc/ssh/sshd_config
:
ClientAliveInterval 300ClientAliveCountMax 2
These settings allow the SSH client or server to send an empty package to the other end every 5 minutes.
If it does not receive any response after two attempts, give up. The connection is disconnected.
Man ssu_config shows the detailed description:
SYNOPSIS ~/.ssh/config /etc/ssh/ssh_configDESCRIPTION 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)
SSH logon error: packet_write_wait: connection to x. x port 22: broken pipe