SSH allows secure (encrypted and authenticated) connections between two hosts. These connections include terminal sessions, file transfers, TCP port forwarding, as well as X window forwarding which I will be covering here. X forwarding is a form of tunneling that allows you to run a GUI application on a remote machine but let you view and interact with it on your local machine.
To try this out you will need both X and SSH installed on your local and remote machines. Make sure that you are able to log into the the remote machine over SSH before you continue.
Simple SSH command, ensure that this works before continuing. You may have to enter a password for the user before it will allow you access.
$ ssh user@remotehost
The next step is to add the ‘-X‘ option. This will turn on X forwarding and allow you to remotely run X programs. In this case we will run xclock.
$ ssh -X user@remotehost xclock
You should see the xclock window appear on your screen. You can interact with it like any other local application window. Close it when you are done.
If you have a slower connection you can turn on compression by adding the ‘-C‘ option to the command above. This will compress all data communications with the gzip algorithm.
$ ssh -C -X user@remotehost xclock
If you are experiencing any problems turn on verbose output with the ‘-v‘ option. This will give you a lot more output and tell you what is going on underneath.
$ ssh -v -X user@remotehost xclock
If you are still having issues look in the ssh configuration file here/etc/ssh/ssh_config, and make sure that you don’t have X forwarding settings disabled.
Comments (2)
on December 4, 2008 at 9:46 am
Great information, Thanks.
on December 4, 2008 at 9:39 am
You can also login and then run X programs as separate steps:
ssh -X user@remotehost
remotehost> xlogo
remotehost> xclock
If X forwarding doesn’t work, you may need to check it hasn’t been disabled on the remote host – look in /etc/ssh/sshd_config on the remote host.
You can also daisy-chain hosts if you need to access one server via another, for example:
ssh -X user@remotehost
remotehost> ssh -X user2@remotehost2
remotehost2> xlogo
If you want to default ssh to always use ‘-X’ either set up an alias or create a file ~/.ssh/config and add this line to it:
ForwardX11=yes
Trackbacks (0)