Contents[Show]

1. 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.

 

2. Sharing a ssh-session

  1. Start a terminal and connect to the remote server. Then become root.
    lanfear $ ssh sorin@cyndane2
    cyndane2 $ sudo -i
    cyndane2 # whoami
    root
    cyndane2 # 


  2. Start a screen session. The -S flag names this particular session.
    # screen -S shared


  3. 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 on
    Multiuser is now enabled.

  4. Press control-a and (shift):. You should again see a small :-prompt at the bottom of the screen. Type the following and press enter.
    #
    :acladd root
    We've now shared the root user's session.

  5. 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.


  6. Terminate the sessions by pressing control-d as per usual.


 

 

 

 

 

 

 

 

 

 

 

3. Sources

https://askubuntu.com/questions/117487/using-ubuntus-screen-command-to-share-screens