6

I have two machines. I SSH'd into one. I want whatever I type on one to display on the screen of the other. I know you can do this with the GNU screen command. How?

Thanks!

4 Answers 4

9

You do this using the multiuser function of screen.

Assuming you use the same user name to ssh in and connect ...

1) Start a ssh session

ssh user@server

2) start a screen session, -S names the session

screen -S shared

3) Enable multiuser.

Ctrl+a+:

:multiuser on

Ctrl+a+:

 :acladd user2

4) Now on the server , you can connect with

screen -x user2/shared

I wrote a detailed description of how to do this on my blog

http://blog.bodhizazen.com/linux/shared-ssh-sessions-update-for-jaunty-ubuntu-904/

Some of the information in that blog is a bit dated, but, it covers additional issues of security and more then one user. should get you started.

1
  • Note that the ssh user must be different from the _acladd user. user2 would be clearer.
    – Jaime M.
    Oct 15, 2015 at 8:37
3

In your first session, start screen:

screen

Then, on that same machine (either locally or by ssh) connect to the existing screen. To do this you do

screen -x <session name>

Where "session name" is the name of the screen you started above. To find this you can list all running screens like so:

screen -ls

And then you could copy the name of the screen you'd like to attach to.

Alternatively, if you only have one screen session running, you can just type screen -x and then hit tab to autocomplete.

You might also like to look into a program called 'byobu' which is like a fancy front-end to screen. You can keep multiple screens open, kind of like tabs, and it has easier to remember shortcuts for attaching, detaching, switching between screens, etc.

The default setting for byobu is to attach to a session which is already running, if there is one, which makes what you want to do nice and easy. You would just type byobu in each terminal.

0
1

I got the following error when I first used 'screen' in multi-user mode.

"Must run suid root for multiuser support."

Which was easily fixed by running:

sudo chmod u+s /usr/bin/screen
0

It took me some time, but what I found is: The version of screen 4.06 has a bug. If you want to send a command over a shared screen session like this, it fails:

screen -S shared_session_name -X stuff "command \n"

Screen fails with an error:

Cannot opendir /run/screen/S-$USER: Permissions denied

After updating to the version screen 4.09 it works.

(My original post is - https://stackoverflow.com/a/72138639/15314754)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .