Vagrant asks for password after SSH key update

2019-05-27 04:19发布

问题:

I remade my SSH key after switching to a new machine and just copied over my existing customized Vagrant box I packaged up.

When I tried to ssh into the box, I got the REMOTE HOST IDENTIFICATION HAS CHANGED error. So I cleared the entry out of the known_hosts and ssh'd back into the box. The new key was accepted, but now every time I ssh in I am required to enter the default vagrant password instead of just using my ssh key.

What am I missing here?

回答1:

"The new key was accepted"?
Have you verified that the private key on Host and the public key on Guest paired?
If the key was accepted, no password prompt should pop up.

To verify your private/public keys:

Locate your private key on Host OS(IdentityFile for vagrant):

vagrant ssh-config

Generate public key from private key:

ssh-keygen -y -f private_key > public_key
cat public_key

Compare the generated public_key with the public_key on Guest OS(you can login by password).

cat ~/.ssh/authorized_keys


回答2:

I have this issue and it seems to be caused by multiple VM running. I typed vagrant ssh-congfig and noticed that it reported port 2200 instead of 2222 which I was connecting on. When I connected on 2200 it didn't require password. Not sure if that is same for you but it's what happened to me.



标签: ssh vagrant