Intro
So, I needed to do some long jobs over ssh at work and managed to accidentaly stop it. After some whining, crying and general denial, I decided to read up on the screen command.
Among detaching long-running sessions to minimize problems should the ssh-session disconnect, I found one can use screen to share a ssh-session!
This article starts with how to share the ssh-session. Other tricks will be added later.
Sharing a ssh-session
- Start a terminal and connect to the remote server. Then become root.
lanfear $ ssh sorin@cyndane2
cyndane2 $ sudo -i
cyndane2 # whoami
root
cyndane2 # - Start a screen session. The -S flag names this particular session.
# screen -S shared
- Enable multiuser in this screen-session.
Press control-a and (shift):. You should see a small :-prompt at the bottom of the screen. Type the following and press enter.#
Multiuser is now enabled.
:multiuser on - Press control-a and (shift):. You should again see a small :-prompt at the bottom of the screen. Type the following and press enter.
#
We've now shared the root user's session.
:acladd root - Open a new terminal and connect to the same server. Become root and type this in the second terminal.
# screen -x root/shared
You should now see, live, whatever happens in the other terminal.
Try switching terminals, and type in either. Anything that happens in the current active terminal is mirrored in the other. - Terminate the sessions by pressing control-d as per usual.
Sources
https://askubuntu.com/questions/117487/using-ubuntus-screen-command-to-share-screens