I have a setup where I need to forward X11 from my local machine (laptop) to a Virtual machine. The server hosting this VM cannot be reached directly from my laptop. I need to first login to a gateway and from this gateway, I can access the VM. How can I forward X11 from my laptop to this VM? I have tried following but these do not work:

  1. [laptop # ] ssh -X [gateway]

    [gateway # ] ssh -X [VM]

  2. [laptop # ] ssh -tX [gateway] ssh -X [VM]

I could forward X11 only till the gateway. (DISPLAY variable gets set on gateway)

link|improve this question
feedback

migrated from stackoverflow.com Jan 16 '11 at 5:38

This question came from our site for professional and enthusiast programmers.

1 Answer

What you need to do is to use port forwarding so that you can ssh to the remote machine via port forwarding and then do ssh -X.

ssh -L 2222:[VM]:22 [gateway]
ssh -p 2222 -X localhost

or

ssh -R 2222:[VM]:22 [gateway]
ssh -p 2222 -X [gateway]
link|improve this answer
feedback

Your Answer

 
or
required, but never shown