主机的Hostkey值改变,ssh连接失败

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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:2rAd4Uy45Mm8txcdfvJt7MWhbVVXJG/eZP3R+oCPB3E.
Please contact your system administrator.
Add correct host key in /Users/zhanghao/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/zhanghao/.ssh/known_hosts:3
RSA host key for 192.168.*.* has changed and you have requested strict checking.
Host key verification failed.

gitlab迁移项目,hostkey改变,每个终端也要在跟着改一下。

首先删除原本的ssh key:

rm -rf ~/.ssh/known_hosts

生成新的ssh key

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

一路回车,需要选择的时候输入y

Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/zhanghao/.ssh/id_rsa):
/c/Users/zhanghao/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/zhanghao/.ssh/id_rsa.
Your public key has been saved in /c/Users/zhanghao/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:6NQTy8it6pl6Z2o2KLaiHkb/DPIa1ZislxUYhoAmPx8 your_email@example.com
The key's randomart image is:
+---[RSA 4096]----+
|+ .o             |
|oo. o            |
|o. . .  .        |
|  + E..* o       |
| . B += S        |
|. + +o . .       |
| * *  o          |
|+.B O+o          |
|*=+B*B           |
+----[SHA256]-----+

测试ssh key连接。

$ ssh -T git@github.com

如下面表示已经连接成功:

$ ssh -T git@github.com
Hi yourname! You've successfully authenticated, but GitHub does not provide shell access.

但我出现的是这种情况:

The authenticity of host 'github.com (13.229.XXX.XX)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,13.229.XXX.XX' (RSA) to the list of known hosts.
Hi yourname! You've successfully authenticated, but GitHub does not provide shell access.

在第三行输入yes即可。

更多请阅读官方配置

    原文作者:villelee
    原文地址: https://segmentfault.com/a/1190000015787145
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞