So X11 Forwarding!

Hey there! How’s it going? Today we are going to focus on how to run an application that requires a graphic interface on your Ubuntu server where typically Ubuntu server does not come with GUI. Let’s map your Desktop GUI to the remote server by using X forwarding, It is easy to accomplish X forwarding on Ubuntu using X11 & SSH.

Plus I have already written on Remote login with GUI in Linux – VNC. Read it if you haven’t. It’s another way of getting done same task.

Below is an image of SSH concept.

X11 Forwarding Using SSH Tunneling
Image Courtesy : addictivetips.com

So X11 is a

X11 is a network protocol designed for Unix and similar operating systems to enable remote graphical access to applications. The original X windowing system was announced in 1984 and developed at MIT. A machine running an X windowing system can launch a program on a remote computer. All the CPU processing happens on the remote computer but the display of the application appears on the local machine. – toastytech.com

Configurations – X11

X11 forwarding needs to be enabled on both the client side and the server side.

On the client side, set X11 Forwarding yes must specified in ~/.ssh/config.

On the server side, set X11 Forwarding yes must specified in /etc/ssh/sshd_config.

Next on your server, make sure you have xauth installed.

dasunhegoda@dasun:~$ which xauth
/usr/bin/xauth

If not install xauth using below command.

sudo apt-get install xauth

Login

Configurations are done. piece of cake right? Let’s login in now.

ssh -X -v root@12.34.56.78

If you are trying -X for the 1st time you will see the below O/P.

/usr/bin/xauth: creating new authority file /home/user/.Xauthority

Testing

Let’s test now. The following commands will install Mozilla’s Firefox web browser.

sudo apt-get install firefox

Launch Mozilla’s Firefox web browser.

firefox

What above command will do is, it will use your client GUI and fire up the firefox on the server. Beauty of X11 forwarding.

That’s it. Hope you got an idea how to do X11 forwarding. If you have any questions let me know in the comments below. Your feedback is highly appreciated(happy-face).

Loading

6 Comments

  1. Natalia Díaz Rodríguez April 23, 2017 at 3:19 pm

    I am on my mac and my ~/.ssh/config is empty, i.e., it does not exist. What to do?

    Reply
    1. Jonathan L May 14, 2017 at 7:49 pm

      You can just create it. It normally is non-existent
      You may want to change its permissions to match nearby files with chmod

      Reply
  2. ed peterson July 1, 2017 at 12:49 pm

    Hi: Thanks for your help, but I’m only 1/2 way there (I think): user1@us:~$ firefox
    Error: GDK_BACKEND does not match available displays – from my ssh -X -v login to the server when I tried firefox. (Obviously, it’s not clear to me what’s required on both the server and client for this to work… any help or insight would be appreciated.) – Thanks!

    Reply
  3. César Sinchiguano August 2, 2017 at 7:33 pm

    It does not work. I just follow the step carefully but i can not see on my client machine anything, even I can run program through ssh but I can no see it. what can I do? how can I find the problem?

    Reply
  4. Pingback: [Pi]-1 Setup Orange Pi Zero (2021 ver.) – newini

Leave A Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.