3

I am a Linux user with a frequent need to ssh into remote computers and keep my session there running while disconnecting. And then later connect back to it from the same or a different 'client' computers. There are a number of programs, terminal multiplexers, that solves this problem. I frequently use gnu screen, tmux, etc.

However, they all seem designed around the idea of taking over rendering of the text surface available to them to do a form of 'screen management'. In doing so they override tasks normally handled by the terminal window on the client computer (i.e., the xterm, gnome terminal, etc. from which I am running the ssh). This means that once I start the multiplexer, I can no longer use, e.g., the scrollbar to access the scrollback history, or the search menu of my graphical terminal. I can no longer mouse mark and drag in the window and have it scroll back by itself, etc. Instead, these terminal multiplexer provide their own keyboard-based user interfaces to handle such tasks. I would much prefer if I could keep using the UI of my client terminal as usual.

Hence, is there a terminal multiplexer that provides the function of a virtual tty, which one can attach and detach from at will, but when one is connected it simply just outputs all text into the console "the normal way"? I.e., without doing any form of "screen management"? (I'm imagining that it could still keep a log of recent history internally, so that when one connects, it can spit out this log to provide context to a newly connected client.)

(Answers that point to ways to configure well-known multiplexers to do this are of course acceptable.)

2 Answers 2

1

A very simple "terminal session manager" is dtach, or the similar newer abduco. They run a command and communicate with it via a Unix domain socket. They allow you to detach from it and reattach to it many times at once. You would first ssh to the machine then attach to the command you left detached earlier. Unfortunately, there is no log of recent output when you attach, so you might want to use something like script to save output to a log file.

1
  • This was exactly what I was looking for, thanks! dtach is even available directly in ubuntu apt. I much prefer this answer over the other, since these are simple remote-side application that runs fully inside any remote session and does not need to mess with the transport. The only feature I'm missing now are, as you point out, for the multiplexer to keep a small output log to spit out on reconnect to give a bit of shell context and to preserve and show the output of a command that has been left running. Something like script inside dtach may work, or maybe I can add that feature myself... Sep 30, 2018 at 19:20
1

A possible choice is mosh which is a mobile shell which allows you to reconnect to an ssh from different addresses. However, you need to install the server software on each remote. It initially connects through ssh, then starts the mosh server and moves your connection to a UDP data stream to cope with unreliable and slow data connections.

A similar alternative is the Eternal Terminal which similarly needs its own server on the remote, but then uses TCP.

2
  • Can one detach and later reattach to a mosh session? Can you describe in more detail how to do that? I tried to find out how, and found this: github.com/mobile-shell/mosh/issues/394 Sep 24, 2018 at 22:55
  • You are right, mosh is more for a laptop "A" moving from place to place, rather than a person logging in on different machines, "B". If the original mosh client machine A is still accessible from B, you might see if you can ssh from B to A then use something like reptyr to move the pty on A to your new ssh pty (and then back again on logout). There must be something better than this.
    – meuh
    Sep 25, 2018 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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