Post

SSH X11 Forwarding

X11 forwarding allows you to securely run graphical applications on a server and have the graphical output displayed on your local machine (client). This is particularly useful when you need to run GUI-based applications on a server or remote machine but want to interact with them using your local graphical environment.

  1. Install X11 Server on the Server:

    Use the appropriate package manager for your distribution to install the X11 server on the server if it’s not already installed. For Debian-based systems like Ubuntu, you can use apt:

    1
    2
    
     sudo apt update
     sudo apt install xorg
    

    This command installs the X.Org X server, which is the implementation of X11.

  2. Enable X11 Forwarding in SSH on the Server:

    Edit the SSH server configuration file located at /etc/ssh/sshd_config on the server:

    1
    
     sudo nano /etc/ssh/sshd_config
    

    Set the following options to enable X11 forwarding:

    1
    2
    
     X11Forwarding yes
     X11UseLocalhost yes
    

    Save the changes and exit the editor.

  3. Restart SSH Service on the Server:

    Restart the SSH service on the server to apply the configuration changes:

    1
    
     sudo systemctl restart ssh
    
  4. Test X11 Forwarding from the Client:

    Ensure that the X11 server is installed on your local machine (client) as well.

    After installing X11 and enabling X11 forwarding on the server, you can test it by connecting from your local machine (client) to the server using SSH with X11 forwarding enabled (ssh -X) and running a graphical application, such as xeyes.

    1
    2
    
     ssh -X <username>@<hostname>
     xeyes
    

    This command renders the application from the server and displays it on your local machine (client).

By following these steps, you can install X11 and enable X11 forwarding on a server, allowing you to remotely execute graphical applications and view their output on your local machine (client). Make sure to have X11 installed on both the server and the client for successful operation.

This post is licensed under CC BY 4.0 by the author.