I have two VMs.

  • VM-instance-1
  • VM-instance-2

These two connect to each other over ssh back and forth for some automate tasks using user1.

Issue is that these two gets reprovisioned momentarily and after that we have to manually authenticate fingerprint for ssh to work.

I tried adding id_rsa.pub for each of them to other known_hosts and persist the known_hosts file to replace the new ones after reprovisioning.

However, the issue is every time while reprovisioning when the new ssh-keygen is done it generates new keys, hence the persisting known_hosts is useless.

What can be done for these hosts to remember each other’s and their own fingerprints so we don’t need to manually authenticate fingerprint every time.

  • When you talk about accepting fingerprints, do you mean for the SSH host keys? id_rsa.pub is the user's pubic key, not the host key.
    – muru
    Dec 13, 2022 at 2:12
  • @muru Yes, then i may be confusing it but I am referring to host keys, the prompt you get when you first time try to ssh. Dec 13, 2022 at 2:42
  • You can use StrictHostKeyChecking=accept-new for that (see unix.stackexchange.com/a/33273/70524). But depending on how you're provisioning the systems, you could also just set the SSH host keys yourself.
    – muru
    Dec 13, 2022 at 3:54
  • @muru unfortunately since StrictHostKeyChecking=accept-new will disable fingerprint checking for all machines so cant do it with that, so how can i set the (same) host keys myself and configure other machine to remember those? Dec 13, 2022 at 7:06
  • That depends on how you're provisioning these. If using cloud-init, there's cloudinit.readthedocs.io/en/latest/topics/…
    – muru
    Dec 13, 2022 at 7:29


You must log in to answer this question.

Browse other questions tagged .