Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
somedude@example.com'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.

share|improve this question
    
Can you log into any other remote machines from your macbook air? Can any other machines login to somedude@example.com? –  jessh Dec 16 '13 at 2:47
add comment

1 Answer

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 somedude@example.com 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.

share|improve this answer
1  
Thank you for an excellent answer! –  Will Feb 2 at 18:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.