X Forwarding with Amazon EC2

Thousands people use Amazon EC2 to run they Unix (read Linux) services on the cloud. Sometimes you need to run something that has UI, and you come up to the fact that you need to forward your “X” somewhere out of the EC2 to the available X Windows. You can do it just in 5 minutes.

1. You might need to install some “X” packets
[ec2-user@remote_ec2_box ~]$> sudo yum install xorg-x11-xauth.x86_64 xorg-x11-server-utils.x86_64
1. You should check your sshd config on your remote ec2 box to make sure that X forwarding is enabled:
[ec2-user@remote_ec2_box ~]$> sudo grep X11 /etc/ssh/sshd_config ~/.ssh/* | grep -v '#'
/etc/ssh/sshd_config:X11Forwarding yes

2. Now you need to make “X forwarding”
[user@local_box ~]$> echo $DISPLAY
:0.0 (or :10.0)
[user@local_box ~]$> ssh -X -i ec2-user@remote_ec2_box
[ec2-user@remote_ec2_box ~]$> echo $DISPLAY
[ec2-user@remote_ec2_box ~]$>

Now it should work. But make sure that it will be running very slowly, from/to computer in Seattle corpnet from/to US based EC2 datacenter.

Added later:
Just a snapshot of the steps to run the same scenario from non-EC2 hosts.


[host you want to see result]$ export DISPLAY=:0.0
[host you want to see result]$ echo $DISPLAY
:0.0
[host you want to see result]$ ssh -X -l[user] [host you want to run]
[host you want to run]$ echo $DISPLAY
localhost:10.0
[host you want to run]$ ./app
See the result on the [host you want to see result]

7 Comments

Filed under technology

7 Responses to X Forwarding with Amazon EC2

  1. BestMan1970

    I suggest adding a facebook like button for the blog!

  2. Watch22

    LOL, nice article, my bud was just mentioning some thing opposite to what you’re saying this past day to me. I am gonna have to send him a link to this post.

    • Jacquie

      I’m so very new to programming and am adtldmetiy over my head. How do I login to SSH. I’ve had to access a server using winSCP and Secure CRT before, but that was a company I work for. I had to be guided through that! If you could just point me in the right direction I’ll take it from there. Thanks!!!

  3. Canestraro14115

    I just discovered your site via Google, nice study, heading to sleep now since it’s very late but will check you out much more within the morning.

  4. platinumriver

    Thanks! I tried lots of different things. This one worked great!

  5. david chen

    Excellent article. I absolutely love this site. Stick with it!

  6. Bala

    I am also facing the same issue. I am not enable to invoke .jar file using X11 forwarder using linking by Putty. Any reason why AWS is not allowing this feature to be enabled.

Leave a Reply

Your email address will not be published. Required fields are marked *