ssh

How do I reattach to a detached mosh session?


How do I reattach to a detached mosh session or otherwise get rid of

Mosh: You have a detached Mosh session on this server (mosh [XXXX]).

i.e. what's the mosh equivalent of

screen -D -R

or possibly

screen -wipe

Furthermore, where can this answer be found in documentation?


Solution

  • For security reasons, you can not reattach, see https://github.com/keithw/mosh/issues/394

    To kill the detached session, use the PID number displayed in that message (that's the 'XXXX' part.) For example, if you see --

    Mosh: You have a detached Mosh session on this server (mosh [12345]).

    And can run this command:

    kill 12345
    

    Also, to close all mosh connections you can:

    kill `pidof mosh-server`
    

    Note that if you are currently connected via mosh, this last command will also disconnect you.