I have hosts A,B and C. From host A I can access through ssh only B. From B I can access C. I want to be able to run X11 programs on C and forward display to A.
I tried this:
A$ ssh -X B B$ ssh -X C C$ xclock Error: Can't open display:
But it doesn't work.
There are several ways to do this, the one I prefer is to forward the ssh port:
First, connect to machine B and forward [localPort] to C:22 through B
Next, connect to C from A through this newly-created tunnel using [localPort], forwarding X11
Now we can run X11 programs on C and have them display on A
[localPort] can be any port that you are not already listening to on A, I often use 2222 for simplicity.
This can easily be accomplished using port forwarding:
Port localhost:2022 is forwarded to C:22 via B SSH to C via localhost:2022 Use X as normal
Have you tried with
The -Y flag "Enables trusted X11 forwarding."
For newer versions opensshd you have to disable
X11UseLocalhost
for this to work.You need to do this on Host C's
/etc/ssh/sshd_config
and restart sshd for this to work:Assuming the problem is that the middle machine doesn't have X, but it otherwise configured to allow forwarding X11, just install xauth.
on a yum-based system (fedora, redhat, centos):
on an apt-based system (debian, ubuntu):
If you often go from A to C, you can configure B as a proxy:
A:~/.ssh/config
:then it's just:
You could combine -Y/-X command with the -J command line option:
If you have more Hosts to hop than just do the following:
From man ssh:
It was introduced in OpenSSH version 7.3 (released in August 2016).
You can't forward X11 display if you have X11Forwarding disabled in any sshd you are using.
man sshd_config:
You have to make sure X11Forwarding is enabled on destination and all intermediate sshds you are using.
Just a small hint: you should try to use VNC, X11 display forwarding is quite bandwidth consuming.