Sharing a Single bash Session

Problem

You need to share a single bash session for training or troubleshooting purposes, and there are too many people for “over the shoulder” to work. Or you need to help someone who’s located somewhere else, and you need to share a session across a network.

Solution

Use GNU screen in multiuser mode. The following assumes that you have not changed the default metakey from Ctrl-A as described in Recovering Disconnected Sessions Using screen. If you have, then use your new metakey (e.g., Ctrl-N) instead.

As the host do the following:

  1. screen -S session_name (no spaces allowed); e.g., screen -S training.

  2. Ctrl-A :addacl usernames of accounts (comma delimited, no spaces!) which may access the display; e.g., Ctrl-A: addacl alice,bob,carol. Note this allows full read/write access.

  3. Use the Ctrl-A: chacl usernames permbits list command to refine permissions if needed.

  4. Turn on multiuser mode: Ctrl-A: multiuser on.

As the viewer, do this:

  1. Use screen -x user/name to connect to a shared screen; e.g., screen -x host/training.

  2. Hit Ctrl-A K to kill the window and end the session.

Discussion

See Recovering Disconnected Sessions Using screen, for necessary details.

For multiuser mode, /tmp/screens must exist and be world-readable and executable.

screen versions 3.9.15-8 to 4.0.1-1 from Red Hat (i.e., RHEL3) are broken and should not be used if you want multiuser mode to work. Version 4.0.2-5 or later should work; for example, http://mirror.centos.org/centos/4.2/os/i386/CentOS/RPMS/screen-4.0.2-5.i386.rpm ...

Get bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.