Enable X11 forwarding in SSH

This method is used to run X11 (GUI based) programs in remote machine, and output the display to the local machine. The purpose is almost similar to VNC and such, though they are technologically very different.

To use this feature, simply add the -X option when running SSH. Below is a sample SSH command.

ssh -X user@remote-machine

To execute a program on the remote machine and output the display locally, just type the program name at the terminal and you sould get the forwarded display on your desktop.

If it fails, set the these options in the remote machine’s /etc/ssh/sshd_config as the following and then restart the SSH service;

X11Forwarding yes

If it still doesn’t work, try to check your local machine’s /etc/ssh/ssh_config and set these option as the following;

ForwardX11 yes

If you get permission error, run the following command at you terminal;

xhost +

Sign up for Complete Secure Shell Course and many other great courses on Udemy to learn more.

Complete Secure Shell Course

This course is made for Linux admins who seek to secure their Linux work environment by mastering Linux SSH security!

Written by Mohd Shakir Zakaria. Last updated on 2019-02-12