X11 forwarding via SSH

X11, as I suppose most of you know, is the graphical server used by almost all Linux distributions. This server allows, among other things, forwarding via SSH. This means that it is possible to run graphical applications from a remote machine by exporting the display to our desktop. That is, the application runs on the remote server, but the graphical interface is displayed on our local desktop.


Steps to follow

1.- On the server, edit the file / Etc / ssh / ssh_config and modify the option X11Forwarding so it looks like this:

X11Forwarding yes

After this change, it may be necessary to restart the ssh daemon. The way to do this varies according to each Linux distribution. The simplest is to restart the machine.

2.- On the local desktop, log in to the server via SSH using the -X parameter:

ssh -X user @ hostname

Where user is the username used to log into the server and hostname is the IP or alias of the server.

3.- To run an application, you just have to do it from the terminal. For example:



Trusted X11 forwarding

By enabling Trusted X11 forwarding, it is possible to speed up the connection speed a bit, since some steps related to its security are avoided.

In case speed is more important than safety, all that needs to be done is the following:

1.- On the server, edit the file / Etc / ssh / ssh_config and modify the option ForwardX11Trusted so it looks like this:

ForwardX11Trusted yes

2.- On the local desktop, log in to the server via SSH using the -Y parameter:

ssh -Y user @ hostname


Compressed X11 forwarding

In those scenarios where the connection between the server and the client is not the best, it is possible to compress the data sent by the server.

To do this, when logging into the server via SSH, add the -C parameter:

ssh -X -C user @ hostname

The content of the article adheres to our principles of editorial ethics. To report an error click here!.

21 comments, leave yours

Leave a Comment

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



  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   hectorq said

    Difficult, a lot of command.
    I better not complicate my life and run Teamviewer

    1.    eliotime3000 said

      I don't know, but I am more complicated with TeamViewer and its blessed password.

    2.    x11tete11x said

      It seems to me that they are 2 different things, that someone correct me, but this method that is proposed here, is not to raise the entire environment as if teamviewer does it, but for example to put as it says there "firefox" and that in your machine Firefox opens as usual but in truth it is running from the remote machine.

      1.    EGR said

        Indeed, as you have indicated, it is to run firefox (from the server) on your machine. It's just what they are teaching me now.

      2.    let's use linux said

        That's right, champion!
        As a friend would say, do not confuse the many: "one thing is one thing and another is something else." Haha…
        Nah seriously you are right no this method is not comparable with teamviewer.
        Hug! Paul.

  2.   jhona said

    very good, useful above all and the truth is I use it a lot lately 🙂
    the question is: ssh_config or sshd_config? (man sshd_config because not all distros bring it by default, although the ideal is to declare as user in $ HOME / .ssh / config)
    You can also look at the option X11UseLocalhost
    or the classic one with DISPLAY = ip: Xx and xhost,
    and before any problem give the verbose (-v)

    1.    let's use linux said

      That's right ... good contribution!

  3.   Kevin Maschke said

    Well I find it very interesting! Thanks a lot! I will have to test it on my ovh server! 🙂

    1.    let's use linux said

      Ahead! Hug! Paul.

  4.   manuti said

    Very good article. One issue, I use this option a lot to connect to a Raspberry Pi with Raspbian and Lxde, from an Ubuntu with Unity. Very often it happens that application icons look corrupted. What could this be?
    Another thing, I usually add the option to run graphic applications in the background: firefox &

    1.    let's use linux said

      Good contribution to run apps in the background, I had not thought about it.
      Regarding the icons ... does that happen to you using compressed X11 forwarding?
      Hug! Paul.

      1.    manuti said

        No, you have told me about compressed. When I have a hole I'll send you a catch. As additional info I use faenza on Ubuntu, the client, and the default Lxde icons on the server.

        1.    EGR said

          You have the answer there. The service you bring does not imply that you also bring the desktop environment. You are only bringing the service, and with the order you indicate that it is a graphic service. The X that are executed are those of the client, in your case those of Ubuntu with Unity, and it has to interpret the type of icons, giving equivalence from Lxde to Unity, of which it has by default the faenza (coincidence that they explained this to me last week 😛)

  5.   husband said

    very good article !, I until now to something similar to hectorq, I have two serv. without monitor, when I need firefox to download something (wget and transmission are not enough sometimes), I used ssh, startx and entered through vnc / remmina. Quite cumbersome my method, much easier to do x11-forwarding
    PS: in debian the config files change a bit, it seems that ForwardX11 does the same, greetings!

  6.   x11tete11x said

    Now that I'm messing around with a server, this is sooooo good, and mass right now xD, I need to use multisystem but the OS of my notebook is Chakra Linux, and I have to smoke half a gnome compiling it myself to be able to run it, so I'm going to install on the server with Debian, and forwarding xD hahaha

    1.    let's use linux said

      Good, champion!
      I'm glad! Hug!


    Thank you very much for the info!

    Value added:

    I have Ubuntu Server 14.04.1 LTS
    I had problems with: ./Xauthority
    And to make it work you need to make these changes in: / etc / ssh / sshd_config

    # Lifetime and size of ephemeral version 1 server key
    KeyRegenerationInterval 3600
    ServerKeyBits 768
    # Authentication:
    LoginGraceTime 120
    PermitRootLogin yes
    StrictModes yes

    and restart the ssh service: # sudo service ssh restart

    I hope it has served someone.

    1.    let's use linux said

      Good! Thanks for the contribution!
      Cheers! Paul.

  8.   Pablito el balvito said

    Very well explained! There is one thing I don't understand, if the application is running on the remote host, does it mean that the graphics are also processed by the host? In other words, will the host's graphics card process the data and simply send the information to the client for them to view? It occurs to me that this way I could run 3D modeling applications that require much more power from my small notebook.

  9.   butt said

    makes you want to shit

  10.   a member said

    I just say that I want a coat