Mux_client_request_session: read from master failed: Broken pipe ssh error and what does it mean?

Once in a while when I do ssh $USER@$REMOTE_HOST_NAME I get the following error

mux_client_request_session: read from master failed: Broken pipe

What does it mean? I have Ubuntu desktop and Debian 10 server. How can I trace it down?

Do you have ControlPersist enabled in your ~/.ssh/config file? If so, there is no solution other than removing ControlPersist.

What is a ControlPersist option in ssh_config for ssh command?

From the https://man.openbsd.org/ssh_config:

When used in conjunction with ControlMaster, specifies that the master connection should remain open in the background (waiting for future client connections) after the initial client connection has been closed. If set to no (the default), then the master connection will not be placed into the background, and will close as soon as the initial client connection is closed. If set to yes or 0, then the master connection will remain in the background indefinitely (until killed or closed via a mechanism such as the “ssh -O exit”). If set to a time in seconds, or a time in any of the formats documented in sshd_config(5), then the backgrounded master connection will automatically terminate after it has remained idle (with no client connections) for the specified time.

Typical ~/.ssh/config

Host *
   IdentitiesOnly yes
   ControlPath ~/.ssh/logincontrol/%r@%h:%p
   ControlMaster auto
   ControlPersist yes

Take a look at:

Here is what is happening?

  1. You run: ssh $USER@$REMOTE_HOST_NAME from Linux or Unix terminal.
  2. Then logout but due to ControlPersist set to yes, ssh session is kept alive and open for future login.
    Maybe something went wrong with your wifi or network connection, or perhaps the Internet was disconnected for 15 minutes due to ISP issues.
  3. Now persistent connection was broken due to network problem.
  4. So when you run ssh $USER@$REMOTE_HOST_NAME again after a network problem, the ssh tries to reuse the connection from step 1, and opens a new connection after a timeout. Hence, you get that error.

How do I solve, “Mux_client_request_session: read from master failed: Broken pipe” problem?

Either remove ControlPersist option from ~/.ssh/config file or ignore it as the network problem is beyond your control. There is no other option.

How to debug ssh client problem

Pass the -v option and it will give you much needed debug information:

ssh -v user@somewhere
ssh -vv user@somewhere
1 Like

OMG. I never think ssh_config. I added it 6 months back and when my Internet goes down then only it happens. Also ssh -v is cool trick.


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki