12

I sometimes get this error when I try to ssh to a remote host:

mux_client_request_session: read from master failed: Broken pipe

I'm using Macbook Air OS X Lion with this in ~/.ssh/config:

ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r

ControlPersist 4h

ForwardAgent yes

Host [ex]
    HostName [example.com]
    User [somedude]

The error above happens when I do:

ssh ex

Terminal hangs for ~1 min and then displays:

mux_client_request_session: read from master failed: Broken pipe
[email protected]'s password:

I type in my password and it's ok. And if I open another Terminal tab, connection sharing is ok too. How can I fix this? It's not terrible, but it's annoying.

1
  • Can you log into any other remote machines from your macbook air? Can any other machines login to [email protected]?
    – jshawl
    Dec 16, 2013 at 2:47

1 Answer 1

15
+50

You have ControlPersist enabled. My educated guess is that the following happens:

  1. You have connection to example.com
  2. Logout, but because ControlPersist is enabled, session is kept open for future connections.
  3. Something goes wrong with your network connection, and thus, persistent connection breaks.
  4. When you run ssh [email protected] again, it tries to reuse connection from step 2, and opens a new connection after timeout.

No separate option for this timeout is available, according to man ssh_config. To avoid this, don't use ControlPersist. Additionally, I highly recommend using public key login, if possible. You can still have passphrase for your public key, but public key effectively prevents brute-forcing your password over SSH connection.

Additionally, you should not store control files under /tmp. Those should/must be secured, and for that, for example ~/.ssh/master/ssh_mux_%h_%p_%r is way better location. Of course, if you're the only user of your laptop (?), that's not too big issue.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .