Gitlab - git 的身份验证失败太多

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36149862/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:53:01  来源:igfitidea点击:

Gitlab - Too many authentication failures for git

gitsshgitlab

提问by Alexis

My command line git is not working since last week, all I remember is that I init a local folder into git version controlled, and add a remote git ref to it. Then my git is unable to push or pull. It shows:

我的命令行 git 自上周起就无法工作了,我只记得我将本地文件夹初始化为 git 版本控制,并向其添加远程 git ref。然后我的 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.

What's weird is that my version control in JetBrain Idea works fine, it can still pull or push that project which can't be pull in command line.

奇怪的是,我在 JetBrain Idea 中的版本控制工作正常,它仍然可以拉取或推送无法在命令行中拉取的项目。

I've add the id_rsa.pub to gitlab before, and I re-add it again now, but it does not work.

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

My ssh debug info

我的 ssh 调试信息

ssh -v [email protected]

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
abc@LiuzhMacbook:~/.ssh$
abc@LiuzhMacbook:~/.ssh$ ls
authorized_keys  id_rsa           known_hosts      tmp/
abc@LiuzhMacbook:~/.ssh$ rm known_hosts
abc@LiuzhMacbook:~/.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

回答by VonC

You can use a different ssh url in order to reference the right public/private key you want.
Add in your HOME/.ssh a file named config:

您可以使用不同的 ssh url 来引用所需的正确公钥/私钥。
在 HOME/.ssh 中添加一个名为 config 的文件:

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

And change your url:

并更改您的网址:

git clone mygitlab:xxx/myproj.git myproj

That way, you avoid the default ssh behavior which presents every keys for ssh to try.

这样,您就可以避免默认的 ssh 行为,该行为会显示每个密钥以供 ssh 尝试。

回答by Yuvraj Patil

enter image description here

在此处输入图片说明

In SourceTree, try changing SSH Clientfrom PuTTY/Plinkto Open SSH.

在 中SourceTree,尝试SSH Client从更改PuTTY/PlinkOpen SSH

回答by CodeWizard

First of all set your ssh keys.

首先设置你的 ssh 密钥。

If our keys are set correctly - try to restart the ssh-agent

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

eval $(ssh-agent)

You should see the PID of the process and you r keys will load.

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

To add your keys manually use: ssh-add. This will load the keys from you default .sshfolder

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

回答by dina

running on linux
the following worked for me (I use gitlab):

在 linux 上运行
以下内容对我有用(我使用 gitlab):

  eval $(ssh-agent -s)
  ssh-add ~/.ssh/<ssh_directory>
  ssh -T [email protected]

and in one command:

并在一个命令中:

 eval $(ssh-agent -s) &&  ssh-add ~/.ssh/gitlab &&   ssh -T [email protected]

回答by Wolfram J

finally - primitive reboot of the host machine works, but would like to know what really happens...

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