近两天重做了系统,之前的 Key (C:\Users\Username\.ssh整个文件夹)都被存放在了一个很安全的存储设备里面。重做系统后把之前备份的密钥对还原到了上述路径,之后登录业务主机没有影响。
但是今天改了点代码,想到好多天没上传了,寻思 Push 一下,结果报错:
[email protected] MINGW64 /d/projectA (main)
$ git push -u origin main
Load key "/c/Users/Username/.ssh/id_rsa": invalid format
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
还以为是 Key 的问题,但是测试了 Key 是能打印出来的
[email protected] MINGW64 /d/projectA (main)
$ cat /c/Users/Username/.ssh/id_rsa
-----BEGIN OPENSSH PRIVATE KEY-----
[正确的 Key 内容]
-----END OPENSSH PRIVATE KEY-----
测试在 git bash 中不通过
[email protected] MINGW64 /d/projectA (main)
$ ssh -T [email protected]
Load key "/c/Users/Username/.ssh/id_rsa": invalid format
[email protected]: Permission denied (publickey).
但在 cmd (非管理员权限)中正常
Microsoft Windows [版本 10.0.19045.2965]
(c) Microsoft Corporation 。保留所有权利。
C:\Users\Username>ssh -T [email protected]
Hi Username! You've successfully authenticated, but GitHub does not provide shell access.
直接就是一个白丝不得其解,VSCode 里面也没办法正常推送,感觉是权限问题,但是权限上看着又没啥问题,想问问大家有没有什么头绪,先谢过了。