Search code examples
visual-studio-codevagrantvagrant-ssh

Issue with REMOTE-SSH into vagrant using VSCode (Mac)


I am trying to follow this link to try connecting into my vagrant vm box with VSCode in Mac Catalina. But every time I am getting "could not establish connection with default".

The link said to copy the 'vagrant ssh-config' results to ~/.ssh/config. Before I did this, the ~/.ssh folder was empty.

The content of the config file copied from 'vagrant ssh-config' is as follows:

Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /Users/stewartty/udacity-courses/fullstack/vagrant/.vagrant/machines/default/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

Host vagrant
  HostName vagrant
  User vagrant

In VSCode, I installed the Remote-SSH extension. Then I followed exactly to the word as laid out in the link (open command palette and select the ./ssh/config file AND again, open command palette and select 'Remote SSH: Connect to Host... and select 'Default').


Solution

  • I made a rookie mistake - I should have run vagrant up first before trying to remote-ssh using VSCode. I’ve had no problem remoting after running vagrant up.