问题如下:在git push的时候,输入完用户名和密码始终遇到这样的提示:

fatal: Authentication failed

向GitHub仓库添加仓库权限不允许 fatal: Authentication failed

原因是在GitHub网站中没有添加SSH key

1.生成 ssh key

ssh-****** –t rsa

向GitHub仓库添加仓库权限不允许 fatal: Authentication failed

3.将生成的公钥 id_rsa.pub内容拷贝到网站指定位置

向GitHub仓库添加仓库权限不允许 fatal: Authentication failed

4.然后再尝试,问题解决。

向GitHub仓库添加仓库权限不允许 fatal: Authentication failed

参考文章 Generating SSH Keys

补充:

同样的开发环境,换了一个ripo之后,再次push,再次遇到权限不允许的问题,尽管已经添加了公钥

向GitHub仓库添加仓库权限不允许 fatal: Authentication failed

从上面可以看出,这次的问题依然是,使用协议不正确,也就是没对应一个项目,都要将其协议从https修改为ssh。在GitHub,Settings的security中可以看到登录失败和登录成功的note信息的差异。

向GitHub仓库添加仓库权限不允许 fatal: Authentication failed

向GitHub仓库添加仓库权限不允许 fatal: Authentication failed

参考链接:

  1. GitHubHelp--Generating SSH keys

  2. 是否必须每次添加ssh-add (ssh-agent使用和局限)

    针对问题:

    $ git push origin master

    Permission denied (publickey).

    fatal: Could not read from remote repository.


    Please make sure you have the correct access rights

    and the repository exists.