Search code examples
windowssshvagrantputtyxming

SSH into vagrant with X server set up


I am running into problems with setting up X11 forwarding on vagrant VM.

I am running Xming for X server and PuTTY as my SSH client.

This is what I get when I run vagrant ssh-config:

Host default
  HostName 127.0.0.1
  User vagrant
  Port 2200
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile C:/Users/MyName/.vagrant.d/insecure_private_key
  IdentitiesOnly yes
  LogLevel FATAL
  ForwardAgent yes
  ForwardX11 yes

My PuTTY has X11 forwarding enabled and X display location set to 0.0.

When I do echo $DISPLAY I get no response.

I am unsure as to what I configured wrongly. I followed the following advice in setting up my PuTTY client. If there is an easier way to set up VM with X11 forwarding, please, let me know.

For reference these are contents of my Vagrantfile.

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.ssh.forward_agent = true
  config.ssh.forward_x11 = true

end

Solution

  • Install Cygwin with the following packages to resolve the problem as specified in this website:

    • xorg-server
    • xinit
    • xorg-docs (for documentation)
    • openssh (in case this wasn't installed previously)

    Then load up the window using startxwin from the cygwin terminal.

    A note that I discovered later is that it is better to ssh into vagrant using the following command:

    vagrant -Y ssh

    Than:

    vagrant -X ssh

    The latter is performed in untrusted mode as in this answer and times out after a while.