This is something I do so frequently, I don’t even think twice about it. Yet it does require some tweaking. So here’s the magic behind getting x-windows to work over an ssh connection.
1. Let’s make sure you have what we need to get started. If not already installed, let’s install the openssh-server on both the SERVER and CLIENT machines.
sudo apt-get install openssh-server
2. Now let’s backup the config files: (as always the # (octothorpe) is a comment and that, or anything after that does NOT need to be coded!)
cd /etc/ssh # change to the ssh configuration file directory
3. First let’s make backup copies of the files:
sudo cp sshd_config sshd_config.org # back up the SERVER config file (WITH D)
sudo cp ssh_config ssh_config.org # copy over the CLIENT config file (NO D)
4. Using the editor of your choice, let’s change the files to allow x-11 forwarding. First the SERVER file
Let’s change the coding!
gksudo gedit sshd_config # edit the SERVER config file (WITH D)
Find the line and make sure it reads:
X11Forwarding yes
There MAYBE an ‘#’ in front of the line, you may need to remove it!
Save the file!
6. Now we’ll change the client side:
gksudo gedit ssh_config # edit the client side (NO D)
change the lines so they look like:
ForwardX11 yes
ForwardX11Trusted yes
You may need to remove the ‘#’ in front to uncomment.
Save it!
7. Restart ssh
sudo service ssh restart
8. Try it!
-X Enables X11 forwarding.
ssh -X (hostname)
9. Try to bring up gedit on the client side by simply typing:
gedit
If we did your homework right, gedit will come up on the client machine, running under ssh. X rides for free. This is great for remote execution of a programme. Could be any X programme.
10. The programme will NOT show up on the other computer. However if you want to start something, but let the other person use it,
export DISPLAY=:0.0
You lose control though. (thanks for this tip, Loni)
Related Articles
1 user responded in this post
If you configure ssh_config (no D!) to enable the “ForwardX11” and “ForwardX11Trusted” options, you no longer need to use the -X or -Y options to the ssh command. It ‘just works™’
You can also put the “ForwardX11” and “ForwardX11Trusted” commands in your .ssh/config file, to enable X11 forwarding without editing the ssh_config file. Little tips!