8

I'm making heavy use of reusing a shared connection which I open to a remote box at the beginning of my workday.

My .ssh/config looks somewhat like this:

ControlMaster auto
ControlPath ~/.ssh/control:%h:%p:%r

Host remote
HostName login.remote.com
User username
ForwardX11 yes
ServerAliveInterval 300

This works rather nicely with one exception. After establishing a first connection (master connection) this works fine: I can use the terminal with the master connection to do stuff on the remote and I can reuse the master connection in a new terminal by calling ssh remote, which opens a new connection without the need to retype my credentials.

However, if some time has passed (between tens of minutes and hours, I'm not really sure) and I want to open a new connection, this fails and the master connection closes with the message (on the master terminal):

Connection to login.remote.com closed by remote host.
Connection to login.remote.com closed.

and (on the terminal I'm using to open a new connection)

Shared connection to login.remote.com closed.

although it was working perfectly fine just seconds ago (I could execute commands on the remote using the terminal running the master connection.

EDIT:: This is the ssh -vvv remote output for a newly opened session which fails to open properly:

OpenSSH_6.1p1 Debian-4, OpenSSL 1.0.1c 10 May 2012
debug1: Reading configuration data /home/$USERNAME/.ssh/config
debug1: /home/$USERNAME/.ssh/config line 27: Applying options for remote
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 23500
debug3: mux_client_request_session: session request sent
debug1: mux_client_request_session: master session id: 5
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Control master terminated unexpectedly
Shared connection to login.remote.com closed.

This seems kind of odd to me and I suppose it's either a bug or a misconfiguration, can you help out?

2 Answers 2

0

Disable these options in ssh config:

ControlMaster auto
ControlPath ~/.ssh/control:%h:%p:%r
2
  • This worked for me.
    – Skatox
    Jul 3, 2018 at 14:58
  • What does this do?
    – Kvothe
    Apr 12, 2021 at 10:52
0

Make the value of ServerAliveInterval sufficiently small:

ServerAliveInterval 30

You must log in to answer this question.

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