Search code examples
sshvagrant

Vagrant asks for password after SSH key update


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?


Solution

  • "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