Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm wondering if it's possible to share a tmux server socket between different hosts. For example, I have a virtual machine (guest) running inside my host, and I'm running a tmux session in the guest, is it possible for my host machine to access the guest's tmux session and do cool stuff with it? (e.g., sending commands over to the guest's session)?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

A related topic came up on the tmux-users mailing list: Trying to use socat to tunnel tmux socket

Summary:

  • Simply forwarding the in-band, over-the-socket dialog between a tmux client and its server will not work because tmux uses file descriptor passing (the client passes its tty fd to the server).
    • It might be possible to develop a specialized proxy, but it seems like it would be non-trivial—it would need to know enough of the tmux socket protocol to know when to accept and send fds, and it would need a method of proxying the fds and any operations done on those fds.
  • The mailing list poster managed to work out a tmux forwarding system using socat that mostly worked.
    • You could probably set a different initial terminal size by giving the -x and -y options to new-session, but this would not fix resize handling (socat would need to handle and forward SIGWINCH (through TIOCGWINSZ/TIOCSWINSZ ioctls)).
    • It sounds like you might want your “forwarding server” to be in your guest OS, but the linked solution would make the server be in your host OS. You could probably rework it so it goes the other way around.

Unless there is some reason you can not run an SSH server on your guest, it is probably easier to use SSH to login to your guest (let the SSH programs handle connecting over the network and managing the ttys) and attach to (or issue commands to) the resident tmux that way:

host$ ssh guest tmux attach -t console
host$ ssh guest tmux new-session -s 'fiddling around'
# etc.

You can create an SSH key and ~/.ssh/config entries on your host to simplify the ssh command lines (i.e. using just ssh guest above instead of ssh -i guest-user1-key user1@guest-vm-ip).

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.