What are other ways to share a tmux session between two users?

From https://github.com/zolrath/wemux:

wemux enhances tmux to make multi-user terminal multiplexing both easier and more powerful. It allows users to host a wemux server and have clients join in either:

Mirror Mode gives clients (another SSH user on your machine) read-only access to the session, allowing them to see you work, or

Pair Mode allows the client and yourself to work in the same terminal (shared cursor)

Rogue Mode allows the client to pair or work independently in another window (separate cursors) in the same tmux session.

It features multi-server support as well as user listing and notifications when users attach/detach.

It is a shellscript wrapper over tmux - no compiling necessary.


I've tried this on Ubuntu but don't see why it wouldn't work on other unix variants.

If both users are members of a common group and the socket-path uses that group both users will be able to attach fine.

Rather than having to change the permissions of the socket-path every time you create one you could create a specific directory for sockets (I used /var/tmux).

First add a group for tmux users

$ addgroup $TMUX_GROUP

Create a directory with the group set to $TMUX_GROUP and use the setgid bit so that files created within the directory automatically have the group set to $TMUX_GROUP.

$ mkdir /var/tmux
$ chgrp $TMUX_GROUP /var/tmux
$ chmod g+ws /var/tmux

Next make sure the users that want to share the session are members of $TMUX_GROUP

$ usermod -aG $TMUX_GROUP user1
$ usermod -aG $TMUX_GROUP user2

As far as I know, it is not possible to share sessions with other users in a "clean" way.

Also read-only access is not possible, if the client doesn't use the -r switch.

As another terminal multiplexer screen supports the features you are looking for, sadly also in a cumbersome way... I'm not sure if this is an option for you, but maybe someone other will find this useful.

Solution for screen:

Host a session:

  • SUID bit of screen must be set :-/
  • Open the session with screen -S sessionname
  • ctrla + :multiuser on
  • ctrla + :acladd otherUsername

Join a session:

  • screen -x username/sessionname

You can set permission bits for the user (* for all) with :aclchg or :chacl. # appended will affect windows, ? appended will affect the commands.

Examples:

  • :aclchg * -wx "#,?" will set the session permissions to read only for all users
  • :aclchg foo +w 2 will give write access for user foo on window 2
  • :aclchg bar +x detach will give the permission for detaching a session to user bar

Tags:

Tmux

Users