鍍金池/ 問答/Java  Linux/ 設(shè)置ssh公鑰提示遠程主機和本機密鑰不同

設(shè)置ssh公鑰提示遠程主機和本機密鑰不同

我根據(jù)碼云的如下教程設(shè)置,密匙已經(jīng)成功了,最后一步:添加后,在終端(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里面提交代碼也可以成功,但是每次提交的時候都會提示這個問題,說的密匙不同,這是什么原因呢?難道是我在同一臺電腦里面設(shè)置了2次ssh密匙嗎?但是舊的密匙我已經(jīng)刪除了啊。是不是沒有刪除干凈呢?是不是還要在intellij里面哪里要在設(shè)置一下嗎?


如何生成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!
則證明添加成功。

回答
編輯回答
薔薇花

把遠程主機上的秘鑰刪掉,然后重新傳一個.

2017年9月1日 06:24
編輯回答
若相惜

這種問題很簡單,請參考下面的鏈接:
SSH Warning: the RSA host key for differs from the key for the IP address

2017年6月9日 22:12