In theory, it's fairly easy. I practice, there are a few gotcha's. Let's walk through this step by step, and I'll tell you what to look for. Once you validate that everything is correct, you ought to be able to do this lickity-split.
Note: I use Red Hat/CentOS. You may have to make slight variations in commands for your environment.
On "local" make sure xhost
is set correctly. Easy way:
[me@local]$ xhost +
For convenience, check your DISPLAY variable:
[me@local]$ echo $DISPLAY
You should see something like :0
or :0.1
(More later)
Next, use ssh with X-Display forwarding:
[me@local]$ ssh -X middle -l me
Alternately: ssh -X me@middle
Now, here it is important to ensure that your DISPLAY variable is set correctly. On some machines, the login files are configured to set your DISPLAY variable for you. This will break the X-Display forwarding!!
[me@middle]$ echo $DISPLAY
The correct setting will look like this:
localhost:10
or even
localhost:11.1
The incorrect setting will look something like this:
*starting_hostname*:0.0
If you have an incorrect setting, you cannot manually change the DISPLAY environment back. You must find where your login scripts on the "middle" host are changing it and leave it the default.
Third, ssh using X-Display forwarding into server:
[me@middle]$ ssh -X me@server
Check your DISPLAY variable again. The same caveat as above applies here. It must be localhost:[number]
At this point, check that your remote display is working correctly by starting any GUI program and validate that screen appears on the local box.
Once you are sure everything is configured, you can run these commands:
[me@local]$ xhost +
[me@local]$ ssh -X me@middle
[me@middle]$ ssh -X me@server
[me@server]$ gvim my_filename
Additional info:
Port 6000 needs to be open between all of the boxes. That is the X-Display forwarding port.
The X-Display programs & libraries need to be installed on "server." (OS Dependent, can't help you here). IF you program (gVIM) calls the "draw a box api" and the "server" OS doesn't know what that is, it will never work.
(Really what happens is, "server" application says "Draw a box with these coordinates." The "server" X-window system says "OK. But, I don't have a monitor ... oh, wait, I'll just draw the box on the 'localhost' monitor."
"server" and "local" have to have compatible X-windowing systems. I've seen issues where Solaris or AIX talking to a CentOS box doesn't always work.
Unless you are using IP addresses in lieu of hostnames, each of your machines need to be able to resolve all 3 host names to an IP address. Usually, I just ensure that all 3 host/IP names in /etc/hosts. This sounds odd, but I have seen this be an issue. And, FWIW, add FQDN & Short Hostname to /etc/hosts.
scp
etc. under the hood.ProxyJump
configuration setting