IDEA/Windows下配置git ssh 报错 Could not create directory ‘/home/DELL/.ssh‘.

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值