1

I use vagrant with a 3rd party linux box.

The box has the default vagrant/vagrant credentials.

In my Vagrantfile I want it to use ssh so I have this

config.vm.provision :shell, :path => "bootstrap.sh"
config.ssh.private_key_path = "~/.ssh/id_rsa"
config.ssh.forward_agent = true

In my bootstrap script I want to add my public key to authorized_keys. This works if I do it post VM creation.

But when I re-provision the VM from scratch, the VM has not yet received the public key through my bootstrap shell script.

How can I have vagrant install my public key in authorized_keys and authenticate with vagrant/vagrant until this has happened? Or is there a better way?

1 Answer 1

1

Found something that works

Based on this Vagrant insecure by default?

Where we have

config.ssh.private_key_path = ["#{ENV['HOME']}/.ssh/id_rsa", \ 
    "#{ENV['HOME']}/.vagrant.d/insecure_private_key"]

This seems to have the effect that vagrant tries keys until it finds one that works (the example enumerates host file system paths too - very nice indeed.)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.