新机子不配ssh没权限,clone的时候会报下面的错误
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Failed during: git fetch origin master:refs/remotes/origin/master --tags --force
解决流程
1.查看GitHub/Gitee的公钥
主要看ssh设置里有没有你本地的
2.查看本地C:\Users\用户名\有没有.ssh文件夹
如果有,再看看这个目录下有没有id_rsa和id_rsa.pub这两个文件,如果已经有了,可直接跳到下一步。
3.如果没有,git bash,创建SSH Key:
$ ssh-keygen -t rsa -C "youremail@example.com"
把邮件地址换成你自己的邮件地址,然后一路回车,使用默认值即可。
创建后可以在用户主目录里找到.ssh目录,里面有id_rsa和id_rsa.pub两个文件,这两个就是SSH Key的秘钥对,id_rsa是私钥,不能泄露出去,id_rsa.pub是公钥,可以放心地告诉任何人。
4.登陆GitHub/Gitee,打开Account/settings/SSH Keys页面(github)profile/sshkeys(gitee)
然后,点“Add SSH Key”,填上任意Title,在Key文本框里粘贴id_rsa.pub文件的内容,就ok了。
尽情clonepullpush吧!