Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)

share|improve this question

migrated from Jan 16 '11 at 5:38

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

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


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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.