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
Simply CMD-SHIFT-P then "Remote-SSH: Connect to Host..." and the ssh . config entry you just added is automatically listed - you simply select it and voila, vscode connects to your remote vagrant vm!
Command: vagrant ssh [name|id] [-- extra_ssh_args] This will SSH into a running Vagrant machine and give you access to a shell. On a simple vagrant project, the instance created will be named default.
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
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.
Install Cygwin with the following packages to resolve the problem as specified in this website:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With