Mosh should disconnect when remote is rebooted #480

uzytkownik opened this Issue Dec 23, 2013 · 8 comments


None yet
4 participants

When I use ssh and reboot remote a message displaying that remote is rebooted is displayed and ssh session is terminated. mosh needs to be terminated manually.

It would be nice to send the disconnection signal to client when server is being terminated.


keithw commented Dec 23, 2013

Generally speaking, Mosh already does this (just tested with a Debian server).

if it's not working for you, please make sure that your server is sending the kill signal to all processes (including your mosh-servers) before cutting the network. (Also let us know the OS of your server.)

@keithw keithw closed this Dec 23, 2013

It did not worked for me on Gentoo (both server and client) with mosh 1.2.4 while it worked with ssh.


keithw commented Dec 23, 2013

You'll have to take this up with Gentoo -- it needs to send a kill signal (like SIGTERM) to all processes before cutting networking. That's how mosh-server knows it needs to quit.

Sorry for late reply. I have been thought about it a bit and I guess problem should occur at least on all systemd+netctl systems and probably on systemd+NetworkManager (which are probably all Linux distributions but Debian/Ubuntu currently - and Debian's folks talking about moving to Upstart or systemd).

As far as I can tell the correct signal is SIGHUP:

   SIGHUP        1       Term    Hangup detected on controlling terminal or death of controlling process

Which is sent by systemd but is ignored by the mosh.


keithw commented Jan 7, 2014

LSB (ISO/IEC 23360) requires that shutdown (and shutdown -r) send SIGTERM, not SIGHUP. We can patch mosh-server to work around this, but please take this up with systemd. And please submit a pull request -- we'd be eager to merge it if systemd is moving in this direction.

@keithw keithw reopened this Jan 7, 2014

(Sorry - I realized I spoke too soon. sshd reacts to SIGHUP while mosh does not but it's not the issue).

After a thought - the ssh displays a message about shutting down while mosh does not. It looks like mosh is terminating uncleanly and too soon (I guess?). Yay for debugging shutdown issues.

I'll investigate further.


eminence commented Aug 26, 2017

I just tested this on a fresh install of Debian 9 (aka Debian Stretch), which defaults to using systemd these days, as well as my gentoo machine. In both cases, the mosh-client exited cleanly, with no need to manually terminate anything. So now that this appears fixed, I'm going to close this issue.

@eminence eminence closed this Aug 26, 2017


cgull commented Aug 28, 2017

I have made a couple of changes over time that should cause mosh-server to more robustly terminate the client on a server shutdown in some cases. If you are still having problems here, and your SSH sessions do terminate promptly and cleanly, please comment here.

(There are still occasionally systems that bring down their network connectivity before user sessions are closed. That is a different problem which should be addressed at the OS/configuration level.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment