I'm building a vagrant machine (Ubuntu 12.04) with the following requirements:

  • SSH access via Vagrant to a user with sudo-privileges.

I've generated public/private keys (via ssh-keygen) on the host and have moved the public key to the authorized_keys file on the guest. And I have tried a password-less SSH.

A couple of things happen I type vagrant ssh with password-enabled SSH keys:

  • I have to type my keyphrase in on the host machine to SSH into the Guest VM.
  • Each time I type in the correct keyphrase it is not accepted.

Which results in the I get the following error message:

SSH authentication failed! This is typically caused by the public/private
keypair for the SSH user not being properly set on the guest VM. Please
verify that the guest VM is setup with the proper public key, and that
the private key path for Vagrant is setup properly as well.

Then I tried password-less ssh.

vagrant ssh
[email protected]'s password: 


I never set up a vagrant user! It should be user@hostname as I had set it up and can confirm works when I boot the VM in VirtualBox.

How do I get private ssh keys to work properly with vagrant? What to do on the host, what to do on the guest?


In VirtualBox the VM is live but I can't do any of the following commands from vagrant console in addition to the problems with vagrant ssh:

vagrant up vagrant halt

The only vagrant command that works is vagrant suspend. When I use it I can actually halt the machine via vagrant halt. Here is the output:

$ vagrant halt
[default] Attempting graceful shutdown of VM...
SSH authentication failed! This is typically caused by the public/private
keypair for the SSH user not being properly set on the guest VM. Please
verify that the guest VM is setup with the proper public key, and that
the private key path for Vagrant is setup properly as well.

7 Answers 7


I am adding this solution for anyone who comes to this thread:

First open this file on the host machine:

$ sudo vim ~/.vagrant.d/boxes/<yourbox>/include/_Vagrantfile

Verify that config.ssh.private_key_path is set to your private key file. If not update that

ssh to vagrant box with default pwd

$ vagrant ssh (default pwd = ‘vagrant’]

Once in the box:

vagrant@lucid64:~$ sudo visudo -f .ssh/authorized_keys

Add your public key to this file and save the file, and exit the box

vagrant@lucid64:~$ exit

Back to the local machine

$ vagrant halt
$ vagrant up

This worked for me

  • Thanks for this - I am wondering though what if it is possible to ssh into a box as user different from vagrant and use the pub/priv key pair? Further you can set the path to the desired private ssh key from the Vagrantfile like so?
    – rhodee
    Aug 16, 2012 at 13:09
  • 2
    I cannot find folder 'include'. I just find folder 0, then virtualbox, then 4 files - box.ovf, box-disk1.vmdk, metadata.json, Vagranfile . Any ideas what to do then?
    – Darius.V
    May 28, 2015 at 8:16

I had the same problem although it wasn't due to SSH key issues. When starting the machine, Virtualbox worked and brought the guest up fine. I was able to SSH into the machine myself, and vagrant ssh worked although it asked me for a password. I logged in and found the following in /var/log/auth.log on the guest:

Feb 13 10:14:34 spaaza-dev sshd[1468]: Accepted password for vagrant from port 61816 ssh2
Feb 13 10:14:34 spaaza-dev sshd[1468]: pam_unix(sshd:session): session opened for user vagrant by (uid=0)
Feb 13 10:14:34 spaaza-dev sshd[1636]: Received disconnect from 11: disconnected by user
Feb 13 10:14:34 spaaza-dev sshd[1468]: pam_unix(sshd:session): session closed for user vagrant
Feb 13 10:16:44 spaaza-dev sshd[1764]: Authentication refused: bad ownership or modes for directory /home/vagrant

I went in to look at permissions for /home/vagrant:

drwxrwxrwx  6 vagrant vagrant 4096 Feb 13 10:15 vagrant

Not good, something else I'd been doing had inadvertently changed the permissions of the /home/vagrant dir. The following fixed the issue:

# chmod 755 vagrant

drwxr-xr-x  6 vagrant vagrant 4096 Feb 13 10:15 vagrant

After that I shut the machine down, started it again and vagrant did its thing fine. :-)

  • Good tip. I also had to do chmod -R 755 /home/vagrant/.ssh
    – wisbucky
    Jan 10, 2017 at 1:26

Try copying the vagrant insecure public key into the file .ssh/authorized_keys into the guest box.

Hope this resolves your ssh issue.

If you want to make it secure then you can do so by copying your own .ssh/id_rsa.pub into the aforementioned file. And setting the

config.ssh.private_key_path = '~/.ssh/id_rsa'

in your Vagrantfile.


For anyone who gets this problem. it took me ages to fix. (Yet the fix is easy!!) So, According to Vagrant documentation there is a default password for 'vagrant' user which is 'vagrant' without the single quotes. you can read more on the same on their Official website http://docs.vagrantup.com/v2/boxes/base.html


I had similar issues. Eventually I solved it by:

  • Making sure Vagrant and Virtualbox were both up-to-date
  • Making sure VirtualBox Guest Additions were up-to-date by installing vagrant-vbguest plugin GitHub RubyGems :

    vagrant plugin install vagrant-vbguest

Follow the steps to resolve the issue in Mac OS High Sierra :-

  1. I am using vagrant 5.X Version
  2. first of all download the virtual box and don't install it.
  3. Go to the System Preference -> privacy and click on allow download by America..
  4. Lock the above changes and install virtual box.
  5. You will get the install successful done message for your virtual box.
  6. Now go to terminal type vagrant up --provision
  7. It will start running scripts if you have any and download the virtual box for you. 8.You will get the message 'Done'

  8. Make sure the virtual box is installed correctly then only run vagrant command. if you face issue un-install virtual box by running uninstall script that comes with the pkg and try installing again.


On windows vagrant ssh was prompting for password. In my case it was a permissions problem.

I had shared my main user profile with an alternate profile I had setup. The inherited permissions caused ssh to fail, but vagrant didn't pass the error back to its spew. vagrant ssh was prompting for a password.

To find out if this is the case, use vagrant ssh-config to get the location of the generated private key.

ssh -i %privatekey -p 2222 vagrant@localhost

remove inheritance and all additional users to the folder, ssh should work.

on linux ls -la ~/ and ls -la ~/.ssh to see the permissions on your .ssh folder and the keys inside it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .