How to establish ssh key pair when “Host key verification failed”

后端 未结 11 1843
抹茶落季
抹茶落季 2021-01-30 10:17

I have set up ssh key pairs between my desktop and two servers, and from the servers to my desktop, but after reinstalling the OS on my desktop, I can\'t re-establish the key-pa

11条回答
  •  旧巷少年郎
    2021-01-30 10:52

    This issue arises when the host key is expired or changed. you can remove the keys that host is using and try to ssh again, so that you are adding new key that is known to both client and server.

    You can check the keys associated with your hosts with cat /.ssh/known_hosts . Now, You can remove the hosts keys manually or using the ssh-keygen option. You can do either of the following option.

    1. Manual removal of keys

      vim /.ssh/known_hosts

    delete the key that is associated with your host.

    1. Remove key using ssh-keygen

      ssh-keygen -R your_host_or_host_ip

    This will remove your key associated with the host.

    Now, you can ssh to your host as usual and you will be asked if you want to continue to this host. Once your enter yes, this host will be added to your/.ssh/known_hosts with updated key. By now, you should be your host.

提交回复
热议问题