I accidentally deleted my authorized_keys file on my vagrant box and I can't SSH into it anymore but I still have a console connected to it.
How do I go about re-making this folder so it allows me to connect again?
I have my .d.vagrant/insecure_private_key on my host machine, do I need to create a public key of that and move that over or do i need to move the private key over too?
Run the following commands on the host:
cd <vagrant_project_directory>
ssh-keygen -y -f `vagrant ssh-config | grep IdentityFile | rev | cut -d ' ' -f1 | rev`
It will display a public key for the currently configured private key.
Add the result to the ~/.ssh/authorized_keys on the Vagrant box machine.
run vagrant ssh-config to review which private key the VM is using
If you're using the vagrant insecure key, you can
~/.ssh/authorized_keys with 600 modeIf you have used your own private key, repeat the steps but create the public key from your key.
You dont need to move the private key, it must stay local and is only needed for you to login into the VM (unless you ssh from the VM into other servers like github or other ssh which will need the key, but thats another thing)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With