You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Git不遵循IdentityFile配置,仍使用错误密钥的问题求助

Git不遵循IdentityFile配置,仍使用错误密钥的问题求助

前言

先说下背景哈,我之前是照着别的帖子里的建议来配置SSH密钥的,但还是碰到麻烦了。

现状说明

我的~/.ssh/目录下有两个密钥文件:id_dsa_git(专门用来连接GitHub的)和id_rsa。但每次尝试连接GitHub的时候,Git总是会用id_rsa,完全不理我指定的id_dsa_git,这可愁死我了。

我的配置情况

我在~/.ssh/config里已经专门给GitHub做了配置,内容如下:

Host github
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_dsa_git
    AddKeysToAgent yes
    PubKeyAuthentication yes

而且相关文件的权限我也检查过了,都是符合要求的:

.rw------- 824 fauve 27 juil. 15:24 /home/fauve/.ssh/config
.r-------- 672 fauve  6 mars   2022 /home/fauve/.ssh/id_dsa_git

遇到的问题

可Git就是不按配置来,还是用id_rsa。比如我执行这个克隆命令的时候:

git clone git@github.com:torvalds/linux.git

得到的提示里还是出现了和id_rsa相关的问题,还弹出这段错误:

Warning: the ECDSA host key for 'github.com' differs from the key for the IP address '140.82.121.3'
Offending key for IP in ...

备注:内容来源于stack exchange,提问作者fauve

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.16 10:54:34