X11 forwarding is a mechanism that allows graphical interfaces of X11 programs running on a remote Linux server to be displayed on a local client machine. Behind the scene, the X11 output of a remotely running program is authorized to be sent to localhost via an X11 connection between client and a remote server. SSH has an option to securely tunnel such X11 connections, so that X11 forwarding sessions are encrypted and encapsulated. If you would like to set up X11 forwarding over SSH, check out this guideline.
For X11 forwarding, the remote server host doesn't need to have a full X11 system installed. However, at least the server host needs to have xauth installed. xauth is a utility that maintains Xauthority configurations used by server and client for authentication of X11 sessions. To install xauth, do the following on a remote server.
For Debian etch (4.0) and earlier, and Ubuntu 7.04 and earlier:
For Debian lenny (5.0) and higher, and Ubuntu 7.10 and higher:
Then, enable X11 forwarding in sshd, and restart sshd as follows.
The above setup enables X11 forwarding system wide on the server host. If you would instead like to enable X11 forwarding on an individual user basis, you can use user-specific ssh configuration file (i.e., $HOME/.ssh/config). That way, you can use X11 forwarding only when you ssh to the user's account.
Unlike a remote server host, a local client machine needs to have X11 system installed, in order for the display of remotely running X11 programs to be shown. Assuming that is the case, you can open ssh connection from a local machine to the remote server as follows.
Once logged in, you can launch any X11 program on the remote server as usual, and its display will be shown on the local client machine.
Subscribe to Xmodulo
You can have daily Linux tutorials and FAQs delivered to your email inbox. Simply enter your email address below to subscribe to our mailing list. You will receive hands-on guides and carefully written tutorials related to Linux, everything for free.