2016-03-22 235 views
5

我的命令行git自上周以来不工作,我只记得我初始化本地文件夹到git版本控制的位置,并为它添加远程git ref。然后我的git无法推或拉。它显示:Gitlab - git身份验证失败

git clone [email protected]:xxx/myproj.git myproj 
Cloning into 'myproj'... 
Received disconnect from 192.168.xxx.xxx: 2: Too many authentication failures for git 
fatal: Could not read from remote repository. 

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

什么奇怪的是,在JetBrain理念我的版本控制工作正常,但它仍然可以拉或推该项目不能在命令行中拉。

我已经将id_rsa.pub添加到gitlab之前,我现在重新添加它,但它不起作用。

我的SSH调试信息

的ssh -v [email protected]

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 gitlab.xxx.com [192.168.xxx.xxx] port 22. 
debug1: Connection established. 
debug1: identity file /Users/abc/.ssh/id_rsa type -1 
debug1: identity file /Users/abc/.ssh/id_rsa-cert type -1 
debug1: identity file /Users/abc/.ssh/id_dsa type -1 
debug1: identity file /Users/abc/.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 OpenSSH_5.3 
debug1: match: OpenSSH_5.3 pat OpenSSH_5* 
debug1: SSH2_MSG_KEXINIT sent 
debug1: SSH2_MSG_KEXINIT received 
debug1: kex: server->client aes128-ctr hmac-md5 none 
debug1: kex: client->server aes128-ctr hmac-md5 none 
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP 
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY 
debug1: Server host key: RSA d7:11:d8:62:a6:30:1d:4a:c7:f1:99:bd:ba:54:de:60 
debug1: Host 'gitlab.corp.com' is known and matches the RSA host key. 
debug1: Found key in /Users/abc/.ssh/known_hosts:127 
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,password,hostbased 
debug1: Next authentication method: publickey 
debug1: Offering RSA public key: /Users/abc/.ssh/id_rsa.cn0 
debug1: Authentications that can continue: publickey,password,hostbased 
debug1: Offering RSA public key: /Users/abc/.ssh/id_rsa.cn6 
debug1: Authentications that can continue: publickey,password,hostbased 
debug1: Offering RSA public key: /Users/abc/.ssh/id_rsa.cn1 
debug1: Authentications that can continue: publickey,password,hostbased 
debug1: Offering RSA public key: /Users/abc/.ssh/id_rsa.cn2 
debug1: Authentications that can continue: publickey,password,hostbased 
debug1: Offering RSA public key: /Users/abc/.ssh/id_rsa.cn5 
debug1: Authentications that can continue: publickey,password,hostbased 
debug1: Offering RSA public key: /Users/abc/.ssh/id_rsa.cn8 
Received disconnect from 192.168.100.218: 2: Too many authentication failures for git 
[email protected]:~/.ssh$ 
[email protected]:~/.ssh$ ls 
authorized_keys id_rsa   known_hosts  tmp/ 
[email protected]:~/.ssh$ rm known_hosts 
[email protected]:~/.ssh$ ssh -v [email protected] 
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 gitlab.corp.com [192.168.100.218] port 22. 
debug1: Connection established. 
debug1: identity file /Users/abc/.ssh/id_rsa type -1 
debug1: identity file /Users/abc/.ssh/id_rsa-cert type -1 
debug1: identity file /Users/abc/.ssh/id_dsa type -1 
debug1: identity file /Users/abc/.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 OpenSSH_5.3 
debug1: match: OpenSSH_5.3 pat OpenSSH_5* 
debug1: SSH2_MSG_KEXINIT sent 
debug1: SSH2_MSG_KEXINIT received 
debug1: kex: server->client aes128-ctr hmac-md5 none 
debug1: kex: client->server aes128-ctr hmac-md5 none 
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP 
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY 
debug1: Server host key: RSA d7:11:d8:62:a6:30:1d:4a:c7:f1:99:bd:ba:54:de:60 
The authenticity of host 'gitlab.corp.com (192.168.100.218)' can't be established. 
RSA key fingerprint is d7:11:d8:62:a6:30:1d:4a:c7:f1:99:bd:ba:54:de:60. 
Are you sure you want to continue connecting (yes/no)? yes 
Warning: Permanently added 'gitlab.corp.com,192.168.100.218' (RSA) to the list of known hosts. 
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,password,hostbased 
debug1: Next authentication method: publickey 
debug1: Offering RSA public key: /Users/abc/.ssh/id_rsa.cn0 
debug1: Authentications that can continue: publickey,password,hostbased 
debug1: Offering RSA public key: /Users/abc/.ssh/id_rsa.cn6 
debug1: Authentications that can continue: publickey,password,hostbased 
debug1: Offering RSA public key: /Users/abc/.ssh/id_rsa.cn1 
debug1: Authentications that can continue: publickey,password,hostbased 
debug1: Offering RSA public key: /Users/abc/.ssh/id_rsa.cn2 
debug1: Authentications that can continue: publickey,password,hostbased 
debug1: Offering RSA public key: /Users/abc/.ssh/id_rsa.cn5 
debug1: Authentications that can continue: publickey,password,hostbased 
debug1: Offering RSA public key: /Users/abc/.ssh/id_rsa.cn8 
Received disconnect from 192.168.100.218: 2: Too many authentication failures for git 
+0

也许intellij不使用与%HOME%\。ssh相同的密钥?尝试http://stackoverflow.com/a/26427400/6309 – VonC

+0

@VonC谢谢,我只是不想重新创建我的rsa证书,因为我已经在任何地方使用它,例如我的生产服务器的登录ssh验证 – Alexis

+0

您可以使用不同的名称创建任意数量的密钥。 – VonC

回答

5

你可以使用不同的ssh url来引用你想要的正确的公钥/私钥。
添加在您的HOME /的.ssh一个名为配置文件:

Host   mygitlab 
Hostname  gitlab.xxx.com 
User   git 
IdentityFile ~/.ssh/id_rsa.gitlab 
IdentitiesOnly yes 

,改变你的网址:

git clone mygitlab:xxx/myproj.git myproj 

这样,就避免了呈现每个键ssh来试试默认的SSH行为。

3

首先设置您的SSH密钥。

如果我们的密钥设置是否正确 - 尝试重新启动的ssh-agent

eval $(ssh-agent) 

您应该看到进程的PID,你r键,将加载。

要手动添加密钥,请使用:ssh-add。这将加载你的密钥默认.ssh文件夹

+0

ssh-add是我错过的关键一步。谢谢 –

0

最后 - 主机的原始重启工作,但想知道到底发生了什么......

3

enter image description here

SourceTree,尝试从PuTTY/Plink改变SSH ClientOpen SSH