设置ssh公钥提示远程主机和本机密钥不同

我根据码云的如下教程设置,密匙已经成功了,最后一步:添加后,在终端(Terminal)中输入
ssh -T git@git.oschina.net就出问题了。
提示的问题是:
Warning: the RSA host key for 'gitee.com' differs from the key for the IP address '本机ip地址'
Offending key for IP in /c/Users/xsooy-pc/.ssh/known_hosts:1
Matching host key in /c/Users/xsooy-pc/.ssh/known_hosts:2
Are you sure you want to continue connecting (yes/no)?

我选择yes之后,提示:ssh_packet_read: Connection closed

我在intellij里面提交代码也可以成功,但是每次提交的时候都会提示这个问题,说的密匙不同,这是什么原因呢?难道是我在同一台电脑里面设置了2次ssh密匙吗?但是旧的密匙我已经删除了啊。是不是没有删除干净呢?是不是还要在intellij里面哪里要在设置一下吗?


如何生成ssh公钥

你可以按如下命令来生成sshkey:

ssh-keygen -t rsa -C "xxxxx@xxxxx.com"

Generating public/private rsa key pair...

三次回车即可生成 ssh key

查看你的 public key,并把他添加到码云(Gitee.com) SSH key添加地址

cat ~/.ssh/id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6eNtGpNGwstc....

添加后,在终端(Terminal)中输入

ssh -T git@git.oschina.net
若返回

Welcome to Git@OSC, yourname!
则证明添加成功。

阅读 3.4k
2 个回答

把远程主机上的秘钥删掉,然后重新传一个.

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题