A related topic came up on the tmux-users mailing list: Trying to use socat to tunnel tmux socket
- 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
-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'
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).