First of all, i set up a separate ssh key for my vagrant box. And i have this setup on my ~/.ssh/config
Host vag_ubuntu14
HostName 127.0.0.1
Port 2222
User vagrant
IdentityFile ~/.ssh/vag_ubuntu14/id_rsa
And i copied the public key to the vagrant box's ~/.ssh/authorized_keys with this command.
cat ~/.ssh/vag_ubuntu14/id_rsa.pub | ssh -p2222 vagrant@127.0.0.1 'cat > ~/.ssh/authorized_keys'
So when running ssh vag_ubuntu14
works as expected.
But running vagrant ssh
to ssh to the vagrant box doesn't work. It produces authentication failure.
Here's my current Vagrant file with the path to the private key already specified.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu14_04"
config.vm.provider "virtualbox" do |vb|
vb.name = "Ubuntu 14.04"
end
config.vm.provision :shell, path: "provision/bootstrap.sh"
config.ssh.private_key_path = '/home/chris/.ssh/vag_ubuntu14/id_rsa'
end
But when i run vagrant ssh-config
, it doesn't respect the custom path to the private key that i specified on my Vagrantfile.
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /home/chris/ubuntu14_04/.vagrant/machines/default/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL