ssh身份验证成功进行git(github.com),但连接关闭

时间:2018-08-17 07:47:51

标签: git ssh

这曾经有效,但现在不再有效。不知道发生了什么变化... 我想通过 github.com 使用 git over SSH -。 我的SSH密钥已上传到github.com

为解决这个谜团,我决定重新生成另一个SSH密钥~/.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_meconfig的访问权限为 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有一些令人讨厌的密钥。 我不是很喜欢,但是该IP地址似乎对github.com是正确的。所以我说了。

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密钥具有读/写访问权限。

添加完整日志:

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.

1 个答案:

答案 0 :(得分:1)

答案在警告中:

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

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

我现在使用git没问题。

经验教训:有关潜在IP冲突/中间人的警告是有价值的信息。要注意他们。如果您没有在另一台服务器上进行过更改,则可能是该路径上有人执行了某些操作。