How to fix SSH Client_loop: send disconnect: Broken pipe Error

Make a fortune with your little hand, give it a thumbs up!

SSH, short for Secure Shell, is a remote network protocol used to securely connect to remote devices, such as servers and network devices, over a TCP/IP network.

It is an encrypted network protocol that provides strong cryptography and hashing to secure communications between two devices on a network.

SSH uses two main authentication methods: password authentication and public key authentication. When using password authentication, the user provides the IP address or FQDN (fully qualified domain name) of the remote host and a password for authentication.

Public key authentication uses an SSH key pair for authentication, and an SSH key pair consists of two SSH keys: a private key and a public key.

The private key resides on the user's machine and should always be kept private and secure. The public key is stored on the remote host that the user connects to. During authentication, the identities of the two keys are compared and access is granted.

When connecting to a remote system via SSH, you may encounter the error Client_loop: send disconnect: Broken pipe.

alt

In this tutorial [1] we will see why this happens and fix the error.

Client_loop: send disconnect: Broken pipe 错误

The error is simply a disconnect message informing you that the SSH connection timeout has been exceeded.

This is a period of inactivity during which no Linux commands are executed or issued from the client. When this happens, the SSH session is terminated, effectively disconnecting you from the remote server.

Most users will usually press "ENTER" or a key on their keyboard to avoid disconnecting from the host due to an idle SSH session. However, this can be tedious and time consuming.

Thankfully, the SSH default configuration settings provide parameters that you can configure to keep your SSH connection active for a longer period of time.

Fix Client_loop: send disconnect: Broken pipe error

To resolve this issue, you need to increase the SSH connection timeout on the client. To do this, modify the default SSH configuration file, usually located at /etc/ssh/sshd_config.

sudo vi /etc/ssh/sshd_config

Be sure to find these two parameters: ClientAliveInterval and ClientAliveCountMax. Let's see what they do.

  • ClientAliveInterval - This is the period of inactivity after which the SSH server sends an alive message to remote clients connected to it.

  • ClientAliveCountMax – This is the number of times the server attempts to send an alive message from the server to the client.

We set these two values ​​as follows:

ClientAliveInterval 300
ClientAliveCountMax 3
alt

This means that after the first 300 seconds (5 minutes) of client inactivity, the server will send an alive message to the client to keep the SSH session active.

If no data or response is received from the client within the next 300 seconds (at the 600 second mark), the server will send another aliveness message again. Finally, after 900 seconds of client inactivity, the SSH connection is terminated or disconnected.

Be sure to save changes to the file before exiting. Then restart the SSH daemon.

sudo systemctl restart sshd

Alternatively, you can connect to your remote client Linux system by specifying the ServerAliveInterval parameter in seconds (300 seconds), which means your SSH session will be active for a maximum of 5 minutes.

ssh -o ServerAliveInterval=300 username@server_ip_address
alt

In this tutorial, we demonstrated how to resolve the Client_loop: send disconnect: Broken pipe error. As you can see, you just need to perform a few tweaks in your SSH configuration files.

Reference

[1]

Source: https://www.tecmint.com/client_loop-send-disconnect-broken-pipe/

This article is published by mdnice multi-platform

Guess you like

Origin blog.csdn.net/swindler_ice/article/details/131097210