Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I keep the fingerprint for the RSA key from changing after every vagrant up command?

I am creating VMs using Vagrant + VirtualBox + CentOS 6.5 (box). Every time I issue the command vagrant up and SSH into the VM, I get the following message.


    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
    Someone could be eavesdropping on you right now (man-in-the-middle attack)!
    It is also possible that a host key has just been changed.
    The fingerprint for the RSA key sent by the remote host is
    SHA256:VGRuX5IMJOd+PW6T4jo/ONm6D8vClUmVEaSI7j/nWb8.
    Please contact your system administrator.
    Add correct host key in /home/root/.ssh/known_hosts to get rid of this message.
    Offending RSA key in /home/root/.ssh/known_hosts:6
    RSA host key for weetube has changed and you have requested strict checking.
    Host key verification failed.

Please note the following.

  • the VM is set to a static IP (e.g. 10.211.55.10)
  • the host machine (Windows) has its hosts file modified (e.g. 10.211.55.10 myvm)
  • I use cygwin to SSH (e.g. ssh root@myvm)

I also tried bootstrapping by copying /etc/ssh to /vagrant/ssh, and then on VM provision, copied /vagrant/ssh/* back to /etc/ssh, but that does not seem to help.

The only way to get around this message is to (using Cygwin) and delete the entry from myvm from ~/.ssh/known_hosts. I don't want to do this every time I have to re-create the VM (e.g. vagrant up).

Any ideas on how to avoid this problem?

like image 464
Jane Wayne Avatar asked Nov 09 '22 08:11

Jane Wayne


1 Answers

I don't know how to make the fingerprint remain the same when rebuilding your VM. However, you can setup your ssh config to ignore the fingerprint (for your VM only!)

In: ~/.ssh/config (i'm using macOS, ssh config file may be located elsewhere in other systems):

Host [IP of your VM]
    StrictHostKeyChecking no
    UserKnownHostsFile=/dev/null
    IdentityFile ~/.vagrant.d/insecure_private_key
like image 88
PGBI Avatar answered Nov 15 '22 06:11

PGBI