Last active
September 12, 2015 21:10
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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