visual-studio-codevagrantvagrant-windowsvscode-remote

How to set a remote connection to a Vagrant container using "Visual Studio Code Remote - SSH"?


I'm exploring the new set extensions called VSCode Remote Pack and I want to connect to a Vagrant container using the Remote Container extension. Using a Windows 10 OS, how could I do that?

I tried the extension but it requests me to have Docker installed, what I suppose from that is that it only works for Docker containers. But I wonder if somebody have already managed to connect to a Vagrant box.

This are the docs from the extension: https://code.visualstudio.com/docs/remote/containers


Solution

  • Sorry for updating this so late.

    The solution was pretty simple, as @MnZrk commented, what it needs to be done for setting up the connection is the following:

    Host default
      HostName 127.0.0.1
      User vagrant
      Port 2222
      UserKnownHostsFile /dev/null
      StrictHostKeyChecking no
      PasswordAuthentication no
      IdentityFile C:/Users/User/project/.vagrant/machines/default/virtualbox/private_key
      IdentitiesOnly yes
      LogLevel FATAL
      ForwardAgent yes
      ForwardX11 yes
    

    Notice that the host name is default, you could rename it to whatever you want so you could identify it more easily.