Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm looking for a clean and easy way to share a tmux session with another user on the same machine. I've tried the -S socket-path option, but it requires opening up all permissions of the socket-path before someone else can connect to the session. It works, but it's a little cumbersome. For example:

# Me
$ tmux -S /tmp/pair
$ chmod 777 /tmp/pair

# Another user
$ tmux -S /tmp/pair attach

This works, but both users now share the same tmux configuration (the configuration of the user who initiated the session). Is there a way to allow the two users to use their own tmux config and their own individual tmux key bindings?

For bonus points, ideally, it would also be nice to give read-only access of the tmux session to other users.

share|improve this question
    
I'm too lazy I just use your question as my answer :D –  phunehehe May 23 '13 at 7:20

4 Answers 4

up vote 15 down vote accepted

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.

share|improve this answer

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
share|improve this answer
    
For what it's worth, I feel that the tmux solution (although slightly more verbose) is actually "cleaner", since it doesn't involve leaving setuid binaries floating around the filesystem. –  Glyph Dec 22 '10 at 21:01
    
Unfortunately, tmux used this in this way has a security issue: those to whom you give access can easily create new sessions and do things in them that you're not seeing. –  Curt Sampson Sep 5 '11 at 5:37

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
share|improve this answer
1  
If you have a filesystem that supports ACLs, you don't need to use a group (and in particular you don't need any root intervention). But this doesn't solve the issue of sharing the tmux configuration, does it? –  Gilles Apr 11 '11 at 20:15

This is not exclusive to tmux, but right now it's what I'm using:

You can use script -f /path/to/some/file to write a terminal session to a file. The -f option updates the file while you tipe.

Someone else (with only read permissions to the file, if you want) can do tail -f to see the file, your terminal session. The -f option makes tail output whatever gets appended.

The combination of the two "sync" the view of a terminal. When used whith tmux, it also has the advantage of avoiding the resize that happens when both users have different resolutions. Another trait is that each user can work on another private window or session.

One potential inconvenience is that some commands (ncurses based for example) may do weird things to the output, escape sequences too (colors). However, I am using this inside tmux, and it seems that tmux fixes those issues. I can see the other user read man pages and use other commands that create buffers, colors are displayed right, etc.

This does not allow to write to each other's terminal though (maybe some other solution could be added for that).

I like to have a window with two panes: one pane running script -f for my peer to see, an another one next to it where I tail -f it's terminal.

It works in ttys as well (and sockets or named pipes may be used too for the file)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.