Configure Ubuntu for X11 Forwarding on startup

How to set up X11 forwarding in Ubuntu

This tutorial shows you how to configure Ubuntu so that X11 forwarding turns on at startup.

1) Open the Terminal in Ubuntu.

2) This is what you should see:

3) Edit the ssh_config file

      • First change directories to /etc/ssh with the command

      • cd /etc/ssh

      • Press Enter

      • Now you are in the /etc/ssh directory and can view all the files in this directory by using the command:

      • LS

      • example: % ls

      • We need to make a change to the ssh_config file

      • Enter the command

        • sudo gedit ssh_config

  • Enter your password and a new text window should open.

3) You should see this:

  • In the new text window, scroll down until you find the lines:

    • # ForwardX11 no

    • # ForwardX11Trusted no

  • We need to change these lines by deleting the # (hash) sign and changing the “no” to “yes”.

    • The # is a comment sign.

    • When you delete # on a line, the command becomes active.

ForwardX11 yes

ForwardX11Trusted yes

4) This is what you should see:

5) Once complete, save the file and close the window.

6) Return to previous directory.

  • Enter the following command to return to the original directory

cd-

6) Now we can remotely connect to a linux server using SSH

  • Type:

ssh username@servername

ssh anteater@maegrad.eng.uci.edu

Press Enter.

  • Enter your password when prompted to do so.

Note: You may be prompted to verify the authenticity of the server you want to connect to.

  • Do so by typing ‘yes’ when prompted.

7) If you want X11 forwarding to run for a specific host during your current ssh session do this:

  • Type:

ssh -X username@servername

ssh -X anteater@maegrad.eng.uci.edu

Press Enter.

  • Enter your password when prompted to do so.

  • Note: This command will only enable X11 forwarding for your current session that you are connected to the maegrad server.