git 权限被拒绝(公钥)

标签 git

当我想设置 ssh 到我的 git 时遇到了一些问题。这是我收到的错误消息。

mbp-op-159:.ssh weiting.cheng$ ssh -vT git@github.com
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to github.com [192.168.1.1] port 22.
debug1: Connection established.
debug1: identity file /Users/c/.ssh/id_rsa type 1
debug1: identity file /Users/c/.ssh/id_rsa-cert type -1
debug1: identity file /Users/c/.ssh/id_dsa type -1
debug1: identity file /Users/c/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Server host key: RSA     16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /Users/c/.ssh/known_hosts:2
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/c/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/c/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).

我按照 git hub 文档上的说明进行操作,但他们没有提到我的问题。

我有私钥

debug1: identity file /Users/c/.ssh/id_rsa type 1

我还将 key 添加到我的 git hub 帐户

git成功获取到我的私钥

debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/c/.ssh/id_rsa

但由于未知原因,git 继续使用我没有生成的 id_dsa。

debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/c/.ssh/id_dsa
debug1: No more authentication methods to try.

然后我的权限被拒绝了。

有人有解决这个问题的建议吗?

最佳答案

您的 key 无效。我建议完全重新开始,所以请继续并删除 ~/.ssh/ 文件夹中的所有内容(known_hosts 除外,您可能应该保留它)。然后运行:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

使用与您的 GitHub 帐户关联的电子邮件地址。确保 key 保存在正确的用户文件夹中。在您的情况下, key 应保存为 /Users/c/.ssh/id_rsa

最后,将 ~/.ssh/id_rsa.pub 的内容复制到剪贴板。转到您的 GitHub 设置,单击 SSH key 选项卡,然后添加您刚刚复制的 key 。

我相信你已经看过了,但这里有一个 more detailed walkthrough .

关于git 权限被拒绝(公钥),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33661079/

相关文章:

git - 在补丁文件中突出显示添加/删除的行,忽略移动

git - 将更改提交到存储库的良好标准是什么?

git log foo..bar——如何查看变更集的* merge 日期*?

git - 在 git revert 之后, merge 显示没有变化并且已经更新

git - 断言当前 HEAD 指向 master 的命令?

git - git-diffall和git difftool --dir-diff无法与Araxis Merge一起使用

git - 本地 git 服务器上的 Jenkins 和 Git 集成

git - 致命 : The remote end hung up unexpectedly while pushing to Git repository

svn - 当文件在两个版本系统下时,如何告诉 emacs VC 我希望文件由 git 管理而不是由 svn 管理?

git推送到远程错误: remote: warning: inexact rename detection was skipped due to too many files