User Rating: 3 / 5

Star ActiveStar ActiveStar ActiveStar InactiveStar Inactive
 

Quick article about how to transfer GUI display on local machine over SSH using PuTTY (or KiTTY) and XServer like Xming/VcXsrv.

Before starting, you'll need
- A windows machine (as local machine)
- A Linux machine (as a remote server)

On local Windows

X Server

Install one of the X Server below on your local Windows:

XDISPLAY over SSH with Putty & Xming/VcXsrv

 

Once install, just click on the program recently installed and a X logo (as below) will appear on the bottom right notification icons.

Xming Server Logo

It means that the XServer is running in the background.

SSH/Telnet client

Install one of theses SSH/Telnet client on your local Windows:

Run the program, and configure it as follow:

XDISPLAY over SSH with Putty & Xming/VcXsrv

Under Connection > SSH > X11 :

  • Check Enable X11 forwarding
  • Enter localhost:0 for "X display location"
  • Check MIT-Magic-Cookie-1

 

XDISPLAY over SSH with Putty & Xming/VcXsrv

Under Session:

  • Select SSH
  • Select "Default Settings"
  • Click Save button

On remote Linux

SSH session

From your local Windows, Open ssh remote session on your Linux machine with PuTTY/KiTTY

  • Check that MIT-MAGIC-COOKIE-1 key has been added with: xauth list
  • Make sure DISPLAY is set to: export DISPLAY=localhost:10
  • Try to display something like: xclock & (if not present, install it with yum install xorg-x11-apps.x86_64)
# Check if MIT-MAGIC-COOKIE-1 key has been added 
[user@oralab01]$ xauth list
    oralab01.uxora.com/unix:10  MIT-MAGIC-COOKIE-1  1a1f7af9b7ca3c11183b529e51529e51

# Make sure DISPLAY variable is set
[user@oralab01]$ env | grep DISPLAY=
    DISPLAY=localhost:10.0

# Display a x11 gui app
[user@oralab01]$ xclock &

An xclock like below should display on your windows desktop :

Note
Please note that display number DISPLAY=localhost:10
should match with the one in xauth list.
Because it can be different from 10.

Tips

SU command

After a su command, you may have the following error if you try to xdisplay something:

    KiTTY X11 proxy: Unsupported authorisation protocol
    Error: Can't open display: localhost:10.0

su open a new session and it does not transfer the session key, so you'll need to manually add the MIT-MAGIC-COOKIE-1 key after the su command.

# Check if MIT-MAGIC-COOKIE-1 key has been added 
[root@oralab01]$ xauth list
    oralab01.uxora.com/unix:10  MIT-MAGIC-COOKIE-1  1a1f7af9b7ca3c11183b529e51529e51

# Change user with su
[root@oralab01]$ su - oracle

# Add the MIT-MAGIC-COOKIE-1 from previous command
[oracle@oralab01]$ xauth add oralab01.uxora.com/unix:10  MIT-MAGIC-COOKIE-1  1a1f7af9b7ca3c11183b529e51529e51
    xauth:  file /home/oracle/.Xauthority does not exist 

# Check if MIT-MAGIC-COOKIE-1 key has been added 
[oracle@oralab01]$ xauth list
    oralab01.uxora.com/unix:10  MIT-MAGIC-COOKIE-1  1a1f7af9b7ca3c11183b529e51529e51

# Set DISPLAY variable
[oracle@oralab01]$ export DISPLAY=localhost:10

# Display a x11 gui app
[oracle@oralab01]$ xclock &

Or you can use the following command before executing the su command:

    su - oracle -c "xauth add $(xauth list | grep MIT-MAGIC-COOKIE-1 | head -1)"
    su - oracle

Or do not use su, but open a new PuTTY/KiTTY session and login with the right user.

Missing charsets warning

    Warning: Missing charsets in String to FontSet conversion
    Warning: Unable to load any usable fontset

If you encounter this warning, set export LC_ALL=C to remove it.

HTH,
Michel.

About MIT-MAGIC-COOKIE-1
A key is only available during the current session open by PuTTY/KiTTY.
For each new PuTTY session, a new key will be generated and display number incremented if already used.

Enjoyed this article? Please like it or share it.

Add comment

Please connect with one of social login below (or fill up name and email)

     


Security code
Refresh