Reverse tunnel method
You can SSH from A to B but you want to SSH from B to A?
A generic solution is to create a reverse SSH tunnel. From SERVER:
ssh -f -N -R 4222:localhost:22 CLIENT
Now you can SSH to port 4222 on CLIENT and log into the server. Turn on X11 forwarding on that connection.
ssh -p 4222 -X localhost
Manual setup method
Alternatively, you can set up X11 forwarding manually to the desired display. If you want to forward display :20
on CLIENT to display :0
on SERVER:
ssh -L 6020:localhost:6000 CLIENT
Applications can only use an X display if they show proper authorization. This takes the form of a “cookie” (randomly generated value that serves as a password). You need to retrieve the cookie value and run the command xauth add :20 MIT-MAGIC-COOKIE-1 …
. See Open a window on a remote X display (why "Cannot open display")?. In your case, you can obtain the cookie value on SERVER by running the command xauth list
in your X session.
Once you've established the TCP forwarding and set the cookie value, set export DISPLAY=:20
and run your application.