最近使用GitHub通过gitbash搭建远程项目过程中
git push -u origin master
出现
Please make sure you have the correct access rights and the repository exists
或者
fatal:Could not read from remote repository.
Pleasemake sure you have the correct access rights
and the repository exists.
这样的问题
查阅资料,主要原因是由于本地(或者服务器上)没有生成ssh key
解决方法:
1、生成你的ssh key;
ssh-keygen -t rsa -C “10022*****@qq.com” 一路回车即可。
ssh -v git@github.com
结尾是:
ssh-agent -s
ssh-add ~/.ssh/id_rsa
这时候应该会提示:
Identity added: …(这里是一些ssh key文件路径的信息)
如果出现错误提示:
Could not open a connection to your authentication agent.
命令:eval ssh-agent -s
后继续执行命令 ssh-add ~/.ssh/id_rsa,这时候一般没问题啦。
2、打开你刚刚生成的id_rsa.pub文件(注意是.pub文件)将里面的内容复制,进入你的github账号,在settings下,SSH and GPG keys下new SSH key,title随便取一个名字,然后将id_rsa.pub里的内容复制到Key中,完成后Add SSH Key。
3、$ssh -T git@github.com
4、再次
$ git push -u origin master
解决了!!!
本文主要参考:
1、王老头:https://www.cnblogs.com/wmr95/p/7852832.html
2、https://blog.csdn.net/jingtingfengguo/article/details/51892864