Skip to content

Instantly share code, notes, and snippets.

@unthought
Last active September 12, 2015 21:10
Show Gist options
  • Save unthought/f5322a71c7be6d6d5131 to your computer and use it in GitHub Desktop.
Save unthought/f5322a71c7be6d6d5131 to your computer and use it in GitHub Desktop.
snippet to configure Vagrant to use SSH agent. Makes it easy to eg. access private git repositories from within VMs.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# ...
# configure Vagrant to use SSH agent. Makes it easy to access git from within VMs.
config.vm.provision "shell" do |s|
ssh_pub_key = `ssh-add -L`
s.inline = <<-SHELL
echo '#{ssh_pub_key}' >> /home/vagrant/.ssh/authorized_keys
echo '#{ssh_pub_key}' >> /root/.ssh/authorized_keys
SHELL
end
config.ssh.forward_agent = true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment