Skip to content

Instantly share code, notes, and snippets.

@vgaidarji
Forked from amosshapira/restore-vagrant-key
Created January 25, 2016 20:11
Show Gist options
  • Save vgaidarji/f8108adf4a07de38a8df to your computer and use it in GitHub Desktop.
Save vgaidarji/f8108adf4a07de38a8df to your computer and use it in GitHub Desktop.
Restore Vagrant authorized_keys on a Vagrant box
#!/bin/bash
MACHINE=$1
# Assume executing in the directory of the Vagrant file
# This command will prompt for the Vagrant user's password, it's usually "vagrant"
ssh-keygen -y -f .vagrant/machines/$MACHINE/virtualbox/private_key | \
vagrant ssh $MACHIME -c "mkdir .ssh; tee -a .ssh/authorized_keys; chmod 0600 .ssh/authorized_keys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment