Skip to content

Instantly share code, notes, and snippets.

@vietlq
Last active August 22, 2023 19:53
  • Star 24 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vietlq/8b20d09fdfe5f02f8b511c7847df39ee to your computer and use it in GitHub Desktop.
Code2Pro: How to Forward X11 to Windows 10 via PuTTY & vcxsrv

Code2Pro: How to Forward X11 to Windows 10 via PuTTY & vcxsrv

Scope

Tested on Windows 10 & Ubuntu 16.

Steps

  1. Check that sshd on Ubuntu is properly configured
sudo vim /etc/ssh/sshd_config

The most important line is X11Forwarding yes (it's added by default, but if not, you can add it).

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
# http://develorium.com/2015/05/remote-eclipse-over-x11/
X11UseLocalhost no

Then reload sshd:

sudo service sshd reload
  1. Install vim-gtk3 or other packages that have UI on Ubuntu
sudo apt-get install vim-gtk3

You can also try gnome-terminal.

For more, check: http://packages.ubuntu.com/xenial/x11/

  1. Install VcXsrv Windows X Server
  1. Configure PuTTY
  • Navigate to SSH => X11 => Tick Enable X11 forwarding
  • Pass the value of $DISPLAY (which is 127.0.0.1:0.0) to the field X display location
  1. Launch from Ubuntu
  • Use PuTTy to log in as normal
  • Run gvim for example on the Ubuntu via PuTTY
  • Use the GVim window

References

@SpareSimian
Copy link

I found it necessary to install xauth on the Linux box (xorg-x11-xauth package on CentOS) to allow the sshd server to accept the X server's DISPLAY variable. Otherwise, $DISPLAY was blank. ("echo $DISPLAY" on the Linux host to test.) Note that the first connection will complain that ~/.Xauthority does not exist. xauth will create that file on the first run.

@revurp
Copy link

revurp commented Jul 31, 2019

I found it necessary to install xauth on the Linux box (xorg-x11-xauth package on CentOS) to allow the sshd server to accept the X server's DISPLAY variable. Otherwise, $DISPLAY was blank. ("echo $DISPLAY" on the Linux host to test.) Note that the first connection will complain that ~/.Xauthority does not exist. xauth will create that file on the first run.

@SpareSimian This worked for me. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment