0%

修复升级Macos 13 Ventura后Git报Pemission Denied的问题

最近尝鲜升级了mac os 13 ventura,结果发现git push代码的时候怎么都不行,直接报了个错误:

1
2
3
4
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights

在反复确认自己的公钥已经放到gitlab上后,开始google,参考了下网上的讨论:https://superuser.com/questions/1749364/git-ssh-permission-denied-in-macos-13-ventura

应该是因为mac os 13中自带的OpenSSH_9.0p1默认禁止了RSA/SHA-1算法导致的。

解决方法的话,要么是生成一个新的ssh密钥,替换下(成本可能有点高):

1
ssh-keygen -t ed25519

要么就是编辑 ~/.ssh/config配置文件,在文件中加入以下的配置即可(还可以应对服务端太老不支持新的加密算法的情况):

1
2
3
Host *
HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
如果我的文字帮到了您,那么可不可以请我喝罐可乐?