我想通过SSH方法(而不是HTTP)推进我的个人github存储库。我有问题。我知道这已经问了很多次了,但我已经尝试了所有的解决方案,但都没有成功。
这就是我迄今所做的..。
我已经通过名为accordingly.
id_rsa.pub的ssh-keygen创建了私有/公共SSH密钥对,它还在“设置”、“-> ssh”和“GPG密钥”下向github添加了id_rsa.pub id_rsa.pub的内容。
git@github.com:<username>/<repository>.git版本添加为远程存储库地址,如果运行git remote -v
ssh-add ~/.ssh/id_rsa
完成所有这些之后,当我运行这个命令ssh -T git@github.com时,它会抛出以下错误:git@34.71.63.211: Permission denied (publickey).
我在这里迷失了,因为我已经尝试了所有的解决方案在网上,但我不知道我做错了什么。
为了方便用户使用,我还运行了命令:ssh -vT git@github.com,下面是结果
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).发布于 2020-07-23 13:43:07
我解决了这个问题。在我的特定场景中,我有一个SSH配置文件(在~/.ssh/config中),其内容如下:
HostName 34.54.65.323 # google cloud IP address
Host gcloud
User faisal
IdentityFile ~/.ssh/id_rsa解决方案是将Host行移到HostName上方,如下所示。
Host gcloud
HostName 34.54.65.323 # google cloud IP address
User faisal
IdentityFile ~/.ssh/id_rsa这很奇怪,因为它与github服务器无关,但它解决了这个问题。我想这可能会对别人有帮助。
https://stackoverflow.com/questions/63053034
复制相似问题