我已经进行了大量搜索并测试了不同的解决方案,但没有成功!
当我想推送我的代码时,我收到以下错误:
Warning: the ECDSA host key for 'git.mywebsite.ir' differs from the key for the IP address '164.138.23.11'
Offending key for IP in /home/alireza/.ssh/known_hosts:10
Matching host key in /home/alireza/.ssh/known_hosts:1
Are you sure you want to continue connecting (yes/no)? yes
Run Code Online (Sandbox Code Playgroud)
每次推送更改时,我应该怎么做才能删除此消息?任何的想法?
c0r*_*0rp 104
它说:
/home/alireza/.ssh/known_hosts 中 IP 的违规密钥:10
因此,出于某种原因,您必须删除known_hosts 中的第 10行。
运行此命令以删除 known_hosts 中的第 10 行:
sed -i '10d' ~/.ssh/known_hosts
Run Code Online (Sandbox Code Playgroud)
或使用 ssh-keygen
ssh-keygen -R git.mywebsite.ir
Run Code Online (Sandbox Code Playgroud)
来自男人的报价
Run Code Online (Sandbox Code Playgroud)-R hostname Removes all keys belonging to hostname from a known_hosts file. This option is useful to delete hashed hosts (see the -H option above).
当我收到消息时:
/home/myusername/.ssh/known_hosts 中的 IP 违规密钥:12
注意行号 - 在我的例子中 - 12
因此,打开“known_hosts”文件并删除第12行。
对我来说这解决了问题。
请注意,如果您找不到 .ssh 文件夹 - .ssh文件夹已隐藏,为了从文件管理器中查看它 - 您必须“显示隐藏的文件和文件夹”。在 Linux Mint 中(也可能在您的发行版中)在文件管理器中 - 有一个显示/隐藏隐藏文件夹的快捷方式 -> Ctrl+H
干杯