SSH into vagrant with X server set up

Matt picture Matt · Nov 20, 2013 · Viewed 18.9k times · Source

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

Answer

m01 picture m01 · May 2, 2015

I had a very similar issue, but in my case it was an issue with the Vagrant VM. Here are some things to check:

  • X11Forwarding needs to be set to yes in /etc/ssh/sshd_config
  • Enable verbose logging for ssh (vagrant ssh -- -vvv -X in Linux, Putty also seems to have a -v command line flag) and look for interesting messages.

With my Vagrant VM the latter revealed the following message:

debug1: Remote: No xauth program; cannot forward with spoofing

After installing a package that provides xauth (xorg-xauth, xorg-x11-xauth or similar), vagrant ssh -- -X worked fine.