Last Updated: March 14, 2016
· akalyaev

SSH agent forwarding with Vagrant

If you want to connect over ssh inside a vagrant box like if you were on your host machine, all you need to do is to add this to your Vagrantfile:

config.ssh.forward_agent = true

This will enable agent forwarding for all ssh connections (

Thanks to @andreysavelyev for spotting this.

2 Responses
Add your response

If you need ssh forward during provisioning there is a fix available here

config.vm.provision :shell do |shell|
    shell.inline = "touch $1 && chmod 0440 $1 && echo $2 > $1"
    shell.args = %q{/etc/sudoers.d/root_ssh_agent "Defaults    env_keep += \"SSH_AUTH_SOCK\""}
over 1 year ago ·

Thanks, nisaacson!

over 1 year ago ·