首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >通过SSH推送Git引发“权限确定(公开密钥)”错误

通过SSH推送Git引发“权限确定(公开密钥)”错误
EN

Stack Overflow用户
提问于 2020-07-23 11:21:23
回答 1查看 492关注 0票数 0

我想通过SSH方法(而不是HTTP)推进我的个人github存储库。我有问题。我知道这已经问了很多次了,但我已经尝试了所有的解决方案,但都没有成功。

这就是我迄今所做的..。

我已经通过名为accordingly.

  • I've和id_rsa.pubssh-keygen创建了私有/公共SSH密钥对,它还在“设置”、“-> ssh”和“GPG密钥”下向github添加了id_rsa.pub id_rsa.pub的内容。

  • 已经将存储库地址的git@github.com:<username>/<repository>.git版本添加为远程存储库地址,如果运行git remote -v

  • I've,则正确地显示通过以下命令将公共SSH密钥添加到SSH代理中,然后ssh-add ~/.ssh/id_rsa

  • I've也尝试重新生成我的私有/公钥,确保密钥文件没有问题。

完成所有这些之后,当我运行这个命令ssh -T git@github.com时,它会抛出以下错误:git@34.71.63.211: Permission denied (publickey).

我在这里迷失了,因为我已经尝试了所有的解决方案在网上,但我不知道我做错了什么。

为了方便用户使用,我还运行了命令:ssh -vT git@github.com,下面是结果

代码语言:javascript
复制
OpenSSH_8.3p1, OpenSSL 1.1.1g  21 Apr 2020
debug1: Reading configuration data /home/<myusername>/.ssh/config
debug1: /home/<myusername>/.ssh/config line 7: Applying options for github.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 34.71.63.211 [34.71.63.211] port 22.
debug1: Connection established.
debug1: identity file /home/<myusername>/.ssh/id_rsa type 0
debug1: identity file /home/<myusername>/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: match: OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug1: Authenticating to 34.71.63.211:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:UVaBouJo6Hj5PeRf1dBhvCPUFWU7fQKpSc7yIYbOE00
debug1: Host '34.71.63.211' is known and matches the ECDSA host key.
debug1: Found key in /home/<myusername>/.ssh/known_hosts:1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/<myusername>/.ssh/id_rsa RSA SHA256:D7Lcobs9L0s5wny5hodYEWxYsZtgOwtati2DgQV7s2M explicit agent
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/<myusername>/.ssh/id_rsa RSA SHA256:D7Lcobs9L0s5wny5hodYEWxYsZtgOwtati2DgQV7s2M explicit agent
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
git@34.71.63.211: Permission denied (publickey).
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-23 13:43:07

我解决了这个问题。在我的特定场景中,我有一个SSH配置文件(在~/.ssh/config中),其内容如下:

代码语言:javascript
复制
HostName 34.54.65.323 # google cloud IP address
Host gcloud
User faisal
IdentityFile ~/.ssh/id_rsa

解决方案是将Host行移到HostName上方,如下所示。

代码语言:javascript
复制
Host gcloud
HostName 34.54.65.323 # google cloud IP address
User faisal
IdentityFile ~/.ssh/id_rsa

这很奇怪,因为它与github服务器无关,但它解决了这个问题。我想这可能会对别人有帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63053034

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档