未完待续~

打开ssh公钥方法:

1.通过命令窗口
a.打开你的git bash 窗口
b.进入.ssh目录:cd ~/.ssh
c.找到id_rsa.pub文件:ls
d.查看公钥:cat id_rsa.pub 或者vim id_rsa.pub

(公钥在用户文件夹下)

生成ssh:

1.首先,如果你没有ssh key的话,在ternimal下输入命令:
ssh-keygen -t rsa -C “youremail@example.com“,途中会让你输入密码啥的,不需要管,一路回车即可,会生成你的ssh key。(如果重新生成的话会覆盖之前的ssh key。)

  
2.然后再ternimal下执行命令:

  ssh -v git@github.com

  最后两句会出现:

  No more authentication methods to try.

  Permission denied (publickey).

3.这时候再在ternimal下输入:

  ssh-agent -s

  然后会提示类似的信息:

  SSH_AUTH_SOCK=/tmp/ssh-GTpABX1a05qH/agent.404; export SSH_AUTH_SOCK;

  SSH_AGENT_PID=13144; export SSH_AGENT_PID;

  echo Agent pid 13144;

4.接着再输入:

  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,这时候一般没问题啦。

5.打开你刚刚生成的id_rsa.pub,将里面的内容复制,进入你的github账号,在settings下,SSH and GPG keys下new SSH key,title随便取一个名字,然后将id_rsa.pub里的内容复制到Key中,完成后Add SSH Key。

6.最后一步,验证Key

  在ternimal下输入命令:

  ssh -T git@github.com

  提示:Hi xxx! You’ve successfully authenticated, but GitHub does not provide shell access.

引用:https://www.cnblogs.com/wmr95/p/7852832.html

本地git报出git@github.com: Permission denied (publickey). fatal: Could not read from remote repository_LiDong的博客-程序员宅基地
https://www.cxyzjd.com/article/qq_36932020/103377586

第一句报错:
fatal: remote origin already exists.
远程起源已经存在。

第二句报错:
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
git@github.com:权限被拒绝(publickey)。
致命:无法从远程存储库读取。

第三句报错:
Please make sure you have the correct access rights
and the repository exists.
请确保您拥有正确的访问权限
并且存储库存在。

经过翻译可以得知我是在上传过程中没有权限所以被拒绝了,经过了对git的一番了解以后得知我好像做少了其中一个比较重要的一步,就是设置一个SSH KEY,即是密钥,(出于安全考虑,Github 服务器和我们本地的通讯要求使用 SSH Key 来验证)。这个时候只需设置一个密钥就行了。


本站由 @Wyatt 使用 Stellar 主题创建。
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。