0

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').

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
punsoca
  • 459
  • 1
  • 7
  • 15

2 Answers2

0

Check your vagrant IP. most of the time has your inet range ip, to see the virtual machine

ifconfig | grep inet

Refer to the Vagrantfile network section

dinobi
  • 530
  • 4
  • 7
  • Looks like its just 127.0.0.1 - here's the `ifconfig | grep inet` results: ` inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 . . .` – punsoca May 26 '21 at 21:46
  • vagrant file location ```vagrant ssh ``` in vm check ip address – dinobi May 26 '21 at 21:58
  • `Vagrant.configure("2") do |config| config.vm.box = "bento/ubuntu-16.04-i386" config.vm.box_version = "= 2.3.5" config.vm.synced_folder ".", "/vagrant" config.vm.network "forwarded_port", guest: 8000, host: 8000, host_ip: "127.0.0.1" config.vm.network "forwarded_port", guest: 8080, host: 8080, host_ip: "127.0.0.1" config.vm.network "forwarded_port", guest: 5000, host: 5000, host_ip: "127.0.0.1"` – punsoca May 26 '21 at 23:53
0

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.

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
punsoca
  • 459
  • 1
  • 7
  • 15