Created
February 18, 2016 05:03
-
-
Save shsteven/7c90b88d3c796ad391f0 to your computer and use it in GitHub Desktop.
Vagrant copy pre-generated ssh keys
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
# Copy local user's SSH key to /home/vagrant/.ssh/id_rsa | |
if File.exists?(File.join("ssh", "id_rsa")) | |
config.vm.provision :shell, :inline => "echo 'Copying local Git SSH Key to VM...'" | |
config.vm.provision :shell, :inline => "mkdir -p /home/vagrant/.ssh && cp /vagrant/ssh/* /home/vagrant/.ssh/ && chmod 600 /home/vagrant/.ssh/*" | |
config.vm.provision :shell, :inline => "sudo chown `id -u vagrant`:`id -g vagrant` /home/vagrant/.ssh/*" | |
else | |
# Else, throw a Vagrant Error. Cannot successfully startup without a GitHub SSH Key! | |
raise Vagrant::Errors::VagrantError, "\n\nERROR: GitHub SSH Key not found at ~/.ssh/id_rsa\n\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment