SSH Keys and Vagrant

Sometimes commands run inside a vagrant box need your SSH key. Installing private packages from Github for example. To do this you need to setup SSH agent forwarding.

To enable agent forwarding add this line to your Vagrantfile.

config.ssh.forward_agent = true

Once that is setup vagrant should forward your keys to the VM when you run vagrant ssh. You can test things have worked by running ssh-add -l inside the VM and see if it finds your key.

If your key is still not available run ssh-add -k outside the VM to add your keys to the local SSH agent.