Skip to content

Instantly share code, notes, and snippets.

@hodak
Created October 6, 2016 12:07
Show Gist options
  • Save hodak/4b5256ac0d3f3b11c51ee5309e60367d to your computer and use it in GitHub Desktop.
Save hodak/4b5256ac0d3f3b11c51ee5309e60367d to your computer and use it in GitHub Desktop.
Add SSH key as authorized key for Vagrant's root
Vagrant.configure(2) do |config|
...
id_rsa_pub = File.read("#{Dir.home}/.ssh/id_rsa.pub")
config.vm.provision "copy ssh public key", type: "shell",
inline: "echo \"#{id_rsa_pub}\" >> /home/vagrant/.ssh/authorized_keys"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment