IDEA/Windows下配置git ssh 报错 Could not create directory '/home/DELL/.ssh'.
IDEA中git 配置 ssh push报错
IDEA中配置git报错如下:git本身路径为Linux格式,所以在windows中使用时,默认路径'/home/DELL/.ssh'
会不匹配
Could not create directory '/home/DELL/.ssh'.
Failed to add the host to the list of known hosts (/home/DELL/.ssh/known_hosts).
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我之前已经在git bash中配好可用,但是不知道为什么IDEA中依旧报错,最后研究许久发现,是我电脑中存在多个git,IDEA中设置的git 是没有配置好的。
总结IDEA中报该项错误:
先在git bash下配好,然后IDEA中git配置切换到git bash 所在的git。
可以使用 which git 查看增正在使用的git路径。
git ssh配置
官方git ssh配置链接,建议照着这个做,网上很多教程都不完整。
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
git ssh 最近更新需要用新的加密方式生成的密钥,SHA-1
类型的不能用了,会报如下错误
ERROR: You're using an RSA key with SHA-1, which is no longer allowed. Please use a newer client or a different key type.
Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
整体流程总结:
1. ssh-keygen -t ed25519 -C "your_email@example.com" 生成密钥对(私钥和公钥.pub两个文件)
2. 把密钥对添加到 ssh-agnet:
# start the ssh-agent in the background
$ eval "$(ssh-agent -s)" 启动ssh-agent
> Agent pid 59566
$ ssh-add ~/.ssh/id_ed25519 添加密钥对
3. 把公钥(.pub结尾文件中内容)粘贴到git账户下
可以用ssh试试能不能运行
ssh -T git@github.com
Warning: the ECDSA host key for 'github.com' differs from the key for the IP address '20.205.243.166'
Offending key for IP in /c/Users/DELL/.ssh/known_hosts:11
Matching host key in /c/Users/DELL/.ssh/known_hosts:22
Are you sure you want to continue connecting (yes/no)? yes
Permission denied (publickey).
$ ssh -T git@github.com
Warning: the ECDSA host key for 'github.com' differs from the key for the IP address '20.205.243.166'
Offending key for IP in /c/Users/DELL/.ssh/known_hosts:11
Matching host key in /c/Users/DELL/.ssh/known_hosts:22
Are you sure you want to continue connecting (yes/no)? yes
Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.
ok
git bash windows下更改.ssh位置
我已经忘记了我当年怎么修改的了,放一个可能的链接。
https://stackoverflow.com/questions/33298729/how-to-change-the-place-where-git-bash-should-look-for-known-hosts-in-windows?rq=3