Using SSH agent forwarding with Vagrant
1 Aug 2013 • 1 minute readSometimes you’ll want to use your local SSH keys on your Vagrant boxes, so that you don’t have to manage password-less keys for each box. This can be done with SSH agent forwarding, which is explained in great detail on Unixwiz.net.
Setting this up is fairly straightforward. On the host machine, you need to add the following to ~/.ssh/config
(which you should create if it doesn’t exist):
host your.domain.com
ForwardAgent yes
You need to replace your.domain.com
with either the domain or the IP address of your Vagrant box. You can wildcard this with host *
, but this is a really bad idea because it lets every server you SSH to access your keys.
Once you’ve done that, just run ssh-add
to ensure you ensure your identities are added to the SSH agent.
Now, add the following to the config block in your Vagrantfile:
config.ssh.forward_agent = true
That’s all it takes. You can make sure it worked by comparing the output of ssh-add -L
on both the host machine and the guest box.