git - ssh 身份验证成功到 git (github.com) 但连接关闭

标签 git ssh

这曾经有效,但不再有效。不知道有什么变化...
我想使用 SSH 上的 git - 在 github.com .
我的 SSH key 上传到 github.com .

为了解开这个谜团,我决定重新生成另一个 SSH key ~/.ssh/id_rsa_me并将其上传到 github.com。
我的 ~/.ssh/config告诉 ssh 将此身份文件用于 github.com

ServerAliveInterval 30

Host github.com
 HostName github.com
 User git
 IdentityFile ~/.ssh/id_rsa_me
 LogLevel DEBUG3
~/.ssh/id_rsa_me 的访问权限和 config 600 .

当我尝试执行 git push origin master例如在我的存储库中,我在调试消息中看到:
debug1: identity file /home/axelle/.ssh/id_rsa_me type 1

好的身份文件被捡到 .好的。
Warning: the RSA host key for 'github.com' differs from the key for the IP address '192.30.253.112'
Offending key for IP in /home/axelle/.ssh/known_hosts:214
Matching host key in /home/axelle/.ssh/known_hosts:251
Are you sure you want to continue connecting (yes/no)? yes

github.com 有一些违规键。我不太喜欢这样,但 github.com 的 IP 地址似乎是正确的。所以我说是的。
debug1: Authentication succeeded (none).
Authenticated to github.com ([192.30.253.112]:22).

对 github.com 的身份验证成功 .那挺好的。那我进去了?

但是,它不起作用并且连接关闭 :
debug1: Entering interactive session.
debug1: pledge: network
debug3: send packet: type 1
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t3 r-1 i0/0 o0/0 fd 4/5 cc -1)

debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Connection to github.com closed by remote host.
Transferred: sent 1552, received 900 bytes, in 0.0 seconds
Bytes per second: sent 13257759.3, received 7688133.6
debug1: Exit status -1
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

请注意,在 github.com 设置中,我的 SSH key 具有读/写访问权限。

添加完整日志:
debug2: resolving "github.com" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to github.com [192.30.253.112] port 22.
debug1: Connection established.
debug1: identity file /home/axelle/.ssh/id_rsa_me type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/axelle/.ssh/id_rsa_me-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
debug1: Remote protocol version 2.0, remote software version libssh_0.7.0
debug1: no match: libssh_0.7.0
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to github.com:22 as 'git'
debug3: hostkeys_foreach: reading file "/home/axelle/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/axelle/.ssh/known_hosts:251
debug3: load_hostkeys: loaded 1 keys from github.com
debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256
debug2: host key algorithms: ssh-dss,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr,aes192-cbc,aes128-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr,aes192-cbc,aes128-cbc
debug2: MACs ctos: hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib,zlib@openssh.com
debug2: compression stoc: none,zlib,zlib@openssh.com
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-rsa
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
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ssh-rsa SHA256:9g8dMOwh2s2BYc389iSRGpPAdllR+8Um/36pJucm+Ks
debug3: hostkeys_foreach: reading file "/home/axelle/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/axelle/.ssh/known_hosts:251
debug3: load_hostkeys: loaded 1 keys from github.com
debug3: hostkeys_foreach: reading file "/home/axelle/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/axelle/.ssh/known_hosts:214
debug3: load_hostkeys: loaded 1 keys from 192.30.253.112
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/axelle/.ssh/known_hosts:251
Warning: the RSA host key for 'github.com' differs from the key for the IP address '192.30.253.112'
Offending key for IP in /home/axelle/.ssh/known_hosts:214
Matching host key in /home/axelle/.ssh/known_hosts:251
Are you sure you want to continue connecting (yes/no)? yes
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug2: key: /home/axelle/.ssh/id_rsa_me (0x55d7be959740), explicit
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug1: Authentication succeeded (none).
Authenticated to github.com ([192.30.253.112]:22).
debug2: fd 4 setting O_NONBLOCK
debug2: fd 5 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Entering interactive session.
debug1: pledge: network
debug3: send packet: type 1
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t3 r-1 i0/0 o0/0 fd 4/5 cc -1)

debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Connection to github.com closed by remote host.
Transferred: sent 1552, received 900 bytes, in 0.0 seconds
Bytes per second: sent 13257759.3, received 7688133.6
debug1: Exit status -1
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

最佳答案

答案在警告中:

Warning: the RSA host key for 'github.com' differs from the key for the IP address '192.30.253.112'

这是由将我路由到 Internet 的路由器上的 SSL 检查(实际上是中间人)引起的。路由器配置错误,已恢复。

我现在使用 git 没有任何问题。

经验教训 :有关潜在 IP 冲突/中间人的警告是有值(value)的信息。请注意他们。如果您没有更改另一台服务器,则可能路径上的某个人做了一些事情。

关于git - ssh 身份验证成功到 git (github.com) 但连接关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51890646/

相关文章:

git - 当提交包含某些关键字时,如何配置 git 存储库以警告/拒绝

ios - 与 Storyboard merge 问题

c++ - netbeans c++ 跨平台(mac和linux)同时与git

amazon-web-services - AWS Lambda : How do I connect to a service that uses IP whitelisting from AWS Lambda?

powershell - Plink和PowerShell的参数问题

c++ - 在 visual studio 中将源文件推送到 bitbucket

ssh - 如何使用 Putty (ssh) 将文件上传到服务器

R语言: open ssh connection

git - 同一设备上的多个 SSH key

xcode - 将 GitHub for mac 与旧的 Xcode 项目一起使用