Is sharing a tmux sockets between hosts possible?
Solution 1:
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 tonew-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.
- You could probably set a different initial terminal size by giving the
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
).