1.遇到的错误
git.exe push -v --progress “origin” master:master
Pushing to git@gitee.com:waitwinter/authority-manage-system.git
Warning: Permanently added ‘gitee.com,180.97.125.228’ (ECDSA) to the list of 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 did not exit cleanly (exit code 128) (1843 ms @ 2021/4/22 16:29:42)
通过百度翻译可知**“权限被拒绝(公钥)”**
2.我的错误原因
在使用ssh向github提交代码时需要一对密钥对,github配置公钥,本地连接时需要用到私钥。在使用gitbash命令ssh-keygen -t rsa
生成秘钥对时,在执行命令时,一股脑的按回车键,最后密钥对会生成在c盘用户下的目录中,这个时候,我干了一件看似非常正常的事情--------------“将生成的文件.ssh从c盘移到了e盘”,然后当我配置完相关的秘钥后,就发现了了如上的错误,最后打开秘钥看,发现生成的秘钥里包含磁盘信息,也就是说,我们不能随便的移动“.ssh(保存秘钥的文件夹)”的位置,否则就会出现上述的错误,导致github上的公钥无法解析我们上传的文件。
所以发现错误:“当生成秘钥对后不要移动.ssh文件夹的位置”
3.可是当我们想将ssh文件保存在指定的位置时又该怎么做呢?(注:这里使用的是gitbash生成密钥对)
复盘命令ssh-keygen -t rsa
在gitbash中输入此命令后,第一次按下回车键时会出现如下界面:
也就是说我们可以指定保存".ssh"的位置,默认是保存位置是"c/users/用户/.ssh".