PuTTY/Xming/sudo notes

Here are some notes on setting up PuTTY to allow X11 forwarding to Xming, ultimately also using sudo.

Ensure the servers you are connecting to have “X11Forwarding yes” set in /etc/ssh/sshd_config. Restart ssh if necessary.

Starting with PuTTY, after you have already set up the Session connection stuff and know you can ssh to the target, in the configuration under Connection
-> SSH
-> X11
-> tick Enable X11 forwarding
-> leave X display local blank
-> tick MIT-Magic-Cookie-1
-> leave X authority for local display blank

Save your putty session.

Start XLaunch
-> Multiple windows
-> Display number : 10
-> Next
-> Start no client
-> Next
-> Clipboard, Native opengl & Disable access control all ticked
-> Next
-> Finish

Now make the Putty connection to the target and you should be able to run xclock to test.

To sudo to root and be able to run X apps:

Run “xauth list” and you should see a list of one or more cookies. Find the one labelled MIT-MAGIC-COOKIE-1 that has the corresponding display number. For example:

sparticus/unix:10 MIT-MAGIC-COOKIE-1 1ccb738692bac9383747ff

Now “sudo su -” to get root access (I’m assuming sudo is already setup to allow this). Then run

xauth add sparticus/unix:10 MIT-MAGIC-COOKIE-1 1ccb738692bac9383747ff
export DISPLAY=localhost:10.0

You should again be able to run an X application like xclock.

If you need to ssh to other servers from your initial PuTTY session and be able to run X11 apps, use ssh -XY [servername] to ensure X11 is forwarded.

About

I'm a freelance UNIX engineer working in the UK. I'm married to Tina and between us we have six children. I'm a bit of an Apple fan boy, and all the Windows machines in the house are a thing of the past now.

%d bloggers like this: