Skip to content

Instantly share code, notes, and snippets.

@yarel79
Last active August 2, 2022 14:11
Show Gist options
  • Save yarel79/ea0da9d98c1cb6e015f484da248a030c to your computer and use it in GitHub Desktop.
Save yarel79/ea0da9d98c1cb6e015f484da248a030c to your computer and use it in GitHub Desktop.
Windows Putty X11 forwarding to Xming

How to forward Linux X11 to Windows hosted X11 server

1. Linux sshd setup

1.1 Modify /etc/ssh/sshd_config and set:

X11Forwarding yes

1.2 Restart sshd:

[pkw@server1 ~]$ sudo systemctl restart sshd

1.3 Check whether xauth/xclock are available

[pkw@server1 ~]# which xauth xclock
/usr/bin/which: no xauth in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
/usr/bin/which: no xclock in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

Install missing pacakges, for Centos7 it is:

[pkw@server1 ~]# sudo yum install -y xorg-x11-xauth xorg-x11-apps

(for other distributions, use your favourite package manager)

2. X11 Server for Windows

2.1 Install Xming X Server for Windows

2.2 Run Xming

3. Putty

3.1 In Connection->SSH->X11 check "Enable X11 forwarding"

3.2 Log into remote host as non-root user

3.3 Check if DISPLAY is set and xclock works

[pkw@server1 ~]$ echo $DISPLAY
localhost:10.0
[pkw@server1 ~]$ xclock

4. root/other user X11 forwarding

In case you can't directly log into user account (e.g. root login over ssh disabled)

4.1 Get authorization string of a logged user

[pkw@server1 ~]$ xauth list
server1/unix:10  MIT-MAGIC-COOKIE-1  28726720a84442cff2e9eaac22945aa8

4.2 Switch to other user

[pkw@server1 ~]$ sudo su - root 
[root@server1 ~]# export DISPLAY=localhost:10.0
[root@server1 ~]# xauth add server1/unix:10  MIT-MAGIC-COOKIE-1  28726720a84442cff2e9eaac22945aa8

4.3 Run test app

[root@server1 ~]# xclock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment