Linux – X11 forwarding doesn’t work with multiple tmux sessions

linuxsshtmuxx11-forwarding

If I start a tmux session locally and leave it open, then ssh in remotely and start a new tmux session (not attaching to the old one, a brand spanking new session) X11 forwarding seems to break. I've tried this workaround for a similar issue with screen but to no avail…

The error message when I try to launch a GUI app (like xeyes) is something to the effect of can't open display: wrong authentication. I actually don't know what it is for sure because it seems like it's outputting a carriage return and overwriting part of the error message with a new one…

For now I just go through and manually close all the tmux sessions that I had started locally before starting my new remote session. Is there any way to get X11 forwarding working with mixed local/remote tmux sessions?

Best Answer

Not 100% sure it'll work for you, but that link didn't work for me either and I just copied the DISPLAY variable from the initial terminal and wrote export DISPLAY=${copied from outside tmux} which worked fine - i.e.

log in ...
echo $DISPLAY # remember this
tmux a
export DISPLAY=${variable from memory}

the function from that link gave me a completely different DISPLAY which didn't work

Related Question