How to handle X11 Forwarding using SSH
If you need to use X applications/GUI over a remote SSH connection via PuTTY, this tutorial is for you.
What you need
- Xming : an X-Server that starts on top of your desktop.
Download Xming and install it. - PuTTY : an SSH client.
Download PuTTY and save it on your hard disk.
Configure Xming
- Click on the Start button in Windows XP, select Xming → XLaunch
At the Display settings dialog box, select Multiple windows and set the Display number as0. Click on Next. - Keep clicking on Next button till you reach the Finish configuration page, then click on the Finish button.
Configure PuTTY
- Start PuTTY.
- In the PuTTY Configuration section, on the left panel, select Connection → SSH → X11
- On the right panel, click on the Enable X11 forwarding checkbox
- Set the X display location as
:0.0 - Click on Session option on the left panel.
- Enter the hostname or IP address in the Host Name textbox
- Save the session.
Running the X applications from PuTTY
- Double-click on your PuTTY session and login. After you login, a file named .Xauthority will be created.
- Check if the DISPLAY variable has been set.
echo $DISPLAY
You should see a meaningful value for $DISPLAY - Start any X application, say xterm.
xterm
The xterm window should open successfully.
Running X apps as root
This requires a little tweak. Suppose your regular user home directory is /var/home/arul and the root user home directory is /root
- If you were able to login as a normal user earlier, a file called .Xauthority would be created in the home directory. Chmod the .Xauthority to 555.
chmod 555 ~/.Xauthority
- Login as root from your regular user account.
su - root
- Copy the .Xauthority from the regular user's home directory to root user's home directory.
cp /var/home/arul/.Xauthority /root
- Now try to open any X apps like xterm or emacs. It should work.
Troubleshooting
If you're not able to open any X apps from the session, you may need to enable X11 SSH Forwarding in the /etc/ssh/ssh_config file
Last Update: 2008








