首页 > 解决方案 > Git权限被拒绝,但可以通过git shell ssh

问题描述

我刚刚安装了 Git,生成了 SSH 对,将 SSH 密钥添加到我的 github 帐户。毕竟我已经ssh -T git@github.com在 Git Shell 中运行了,我收到了一条关于成功的消息:

Hi username! You've successfully authenticated, but Github does not provide shell access.

然后我尝试推送我的项目提交:使用创建存储库git init,提交提交,添加远程:git remote add origin git@github.com:username/Project.git,但是在我使用之后git push origin master我得到了

git@github.com: Permission denied (publickey)
fatal: Could not read from remote repository

我的 SSH 对在里面C://Users/PCUser/.ssh

编辑:另外,里面没有config文件C://Users/PCUser/.ssh,只有 2 个文件:usernameusername.pub. 这可能是原因吗?里面有一个config文件MyProject/.git

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
[remote "origin"]
    url = git@github.com:username/MyProject.git
    fetch = +refs/heads/*:refs/remotes/origin/*

标签: gitauthenticationgithubssh

解决方案


推荐阅读