# [SOLVED] How do I use SCREEN in Multiuser??

## caplan

Okay, this maybe a stupid question, but if there is a solution, I'd be extremelly happy.

Situation:

My team is spread out all across the nation, and I'm doing training with some co-workers and want to check their work.  If I am SSH'd into a server, and a co-worker is also, is there a way I can "shadow" their SSH session?

Basically, I'd like to see what they are typing/program they might be running/error messages they might be seeing.  Currently, copy and paste thru IM is the name of the game, but its rather inconvenient.  If I could shadow their session and watch them work that would be awesome.

Thanks for any advice you guys might have.Last edited by caplan on Tue Dec 19, 2006 7:37 pm; edited 2 times in total

----------

## adaptr

For very obvious reasons, no, you cannot ever "see" someone else's SSH session.

Please.

But you can interact with them in various clever ways; the cleverest by far is to use screen  in multi-user mode.

```
emerge screen
```

and go read...

----------

## caplan

Well obviously stealing someone's SSH session is a no-no... anyways I'll check out screen.  Any tips on options/use?

Thx,

Caplan

----------

## adaptr

Not only is it a no-no - it can't be done.

Which is exactly why people use SSH in the first place.

You won't "check out" screen; you'll use it and end up loving it.

----------

## pjp

Moved from Other Things Gentoo

----------

## wHAcKer

indeed, screen is perfect for this.

You just HAVE to try it.

----------

## caplan

Okay I've started screen on one session, but can't figure out how exactly I'm supposed to attach to it from another session.

On SSH session #1, I've run:

```
screen
```

Which gives me a bash prompt.  On SSH session #2, I can't figure out the command to type to connect to the screen session.  The MAN page says:

```
screen -r sessionowner/[[pid.]tty[.host]]
```

So I tried:

```
screen -r caplan/12345
```

Obviously I'm not understanding the syntax... The 12345 in the above example is the PID from ps.

----------

## adaptr

Well, if you only provide one parameter it has to be the tty, which you can get by running

```
screen -ls
```

For even more fun, try multi-user mode  :Wink: 

You have to allow multi-user on the screen you want to attach to.

You do this by entering screen's command mode by typing:

```
C-a :
```

That's Control-A followed by a colon.

Then, enable multiuser mode:

```
multiuser on
```

Last, run

```
addacl <username>
```

for each user you want to be able to access the screen session.

You probably don't need to do this if you plan to connect to the session using the same username.

Then, and only then, you can run 

```
screen -r owner/pid.tty.hostname
```

----------

## Mad Merlin

Wouldn't that be screen -x, not screen -r? -x connects to a screen session that's already open, of course.

----------

## adaptr

Yes, of course.   :Embarassed: 

----------

## MrUlterior

 *caplan wrote:*   

> Okay, this maybe a stupid question, but if there is a solution, I'd be extremelly happy.
> 
> Situation:
> 
> My team is spread out all across the nation, and I'm doing training with some co-workers and want to check their work.  If I am SSH'd into a server, and a co-worker is also, is there a way I can "shadow" their SSH session?
> ...

 

The best method is to reemerge BASH with the "bashlogger" USE flag.

 *Quote:*   

> bashlogger -  Log ALL commands typed into bash; should ONLY be used in restricted environments such as honeypots

 

I typically then have xtail running on the logs aggregating all user activity in a single screen.

----------

## adaptr

Hardly the best method, since he also wants to see output.

(Anybody would.)

----------

## caplan

Oops forgot about this thread, thanks to adaptr for all the help thus far.  I'm still not quite there.  So I connected to the same server (SERVERA) with two different users (USER1 and USER2) using SSH.  I followed adaptr's instructions for USER1:

 *adaptr wrote:*   

> You have to allow multi-user on the screen you want to attach to.
> 
> You do this by entering screen's command mode by typing:
> 
> ```
> ...

 

When I did this for USER1, then went to USER2 and typed:

```
USER2@SERVERA ~# screen -ls USER1/

Must run suid root for multiuser support.
```

I read somewhere you needed to set SCREEN to run as the root ID, so I did this:

```
root@SERVERA ~# chmod +s /usr/bin/screen
```

Then I tried tried to list the screens again:

```
USER2@SERVERA ~# screen -ls USER1/

Cannot access /tmp/screen-USER1: No such file or directory
```

So I created a "/tmp/screen-USER1" directory and set the permissions to 0700 as SCREEN requested.  When I attempted to list the screen session again, I now get this error:

```
USER2@SERVERA ~# screen -ls USER1/

No Sockets found in /tmp/screen-USER1
```

If I type "screen -ls" as USER1 I get the following output:

```
USER1@SERVERA ~# screen -ls

There is a screen on:

        13483.pts-3.SERVERA  (Multi, attached)

1 Socket in /home/USER1/.screen.
```

So then I tried using USER2 to attach to 13483 which gave me:

```
USER2@SERVERA ~# screen -x USER1/13483

There is no screen to be attached matching 13483.
```

I'm sure this is something really simple, but I can't figure it out (and Google's not being too friendly).  Any help would be appreciated!

----------

## nom de plume

Here's two resources I found:

http://gentoo-wiki.com/TIP_Using_screen#Multi-user_mode

http://www.linux.com/article.pl?sid=06/08/14/1945249

----------

## davidgurvich

Add a '/' after the username.

```
screen -ls USER1/
```

----------

## caplan

Hey Guys,

Thanks for the links, upon reading them and the setting screen to run as root I've decided its better/safer from a security standpoint to have my colleagues login with a temp ID and share the screen of the same user.  I'm marking this thread as solved.  Thank you everyone for your time.

----------

