GitLab SSH要求输入密码(未知密码)身份验证失败

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了GitLab SSH要求输入密码(未知密码)身份验证失败相关的知识,希望对你有一定的参考价值。

不是重复的帖子(我搜索了主题,没有解决密码问题)

这是一个工作设置,SSH证书工作正常。没有在几个月内使用,没有得到ssh无法验证和服务器一直要求git密码...我已经尝试了GitLab中的每个PW集和我的mac上的admin pw,没有任何作用。我在MacBook上发布了以下新证书:

ssh-keygen -o -f ~/.ssh/id_rsa

pbcopy < ~/.ssh/id_rsa.pub

我按照预期第一次得到以下内容(我已经清除了〜/ .ssh`中的known_hosts文件):

The authenticity of host 'example.com (35.231.145.151)' can't be established.
ECDSA key fingerprint is SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'example.com' (ECDSA) to the list of known hosts.

当我使用ssh -vT git@gitlab.com测试ssh连接时,我得到以下结果:

MacBook:exampleCom example$ ssh -v git@example.com
OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to example.com port 22.
debug1: Connection established.
debug1: identity file /Users/example/.ssh/id_rsa type 0
debug1: identity file /Users/example/.ssh/id_rsa-cert type -1
debug1: identity file /Users/example/.ssh/id_dsa type -1
debug1: identity file /Users/example/.ssh/id_dsa-cert type -1
debug1: identity file /Users/example/.ssh/id_ecdsa type -1
debug1: identity file /Users/example/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/example/.ssh/id_ed25519 type -1
debug1: identity file /Users/example/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/example/.ssh/id_xmss type -1
debug1: identity file /Users/example/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.7p1 Debian-5+deb8u7
debug1: match: OpenSSH_6.7p1 Debian-5+deb8u7 pat OpenSSH* compat 0x04000000
debug1: Authenticating to example.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
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:J7RwXfLgnsuMlJNo4M0LotFN+XAi6q7ak2tlzJ6ECTI
debug1: Host 'example.com' is known and matches the ECDSA host key.
debug1: Found key in /Users/example/.ssh/known_hosts:2
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: Will attempt key: /Users/example/.ssh/id_rsa RSA SHA256:ItsLqWD1sVwEdkp3xIffO0PcAGZx2NdqhIuScZrzjqw agent
debug1: Will attempt key: /Users/example/.ssh/id_rsa RSA SHA256:lShiocfZXbNH9Cp3+w+aY6XDcSVDDTyBHC52L5Qc3N0
debug1: Will attempt key: /Users/example/.ssh/id_dsa 
debug1: Will attempt key: /Users/example/.ssh/id_ecdsa 
debug1: Will attempt key: /Users/example/.ssh/id_ed25519 
debug1: Will attempt key: /Users/example/.ssh/id_xmss 
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/example/.ssh/id_rsa RSA SHA256:ItsLqWD1sVwEdkp3xIffO0PcAGZx2NdqhIuScZrzjqw agent
debug1: Authentications that can continue: publickey,password
debug1: Offering public key: /Users/example/.ssh/id_rsa RSA SHA256:lShiocfZXbNH9Cp3+w+aY6XDcSVDDTyBHC52L5Qc3N0
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /Users/example/.ssh/id_dsa
debug1: Trying private key: /Users/example/.ssh/id_ecdsa
debug1: Trying private key: /Users/example/.ssh/id_ed25519
debug1: Trying private key: /Users/example/.ssh/id_xmss
debug1: Next authentication method: password
git@example.com's password: 
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
git@example.com's password: 
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
git@example.com's password: 
debug1: Authentications that can continue: publickey,password
debug1: No more authentication methods to try.
git@example.com: Permission denied (publickey,password).
Have also tried https access and the following error:

MacBook:MyGitRepo jeffb$ git push origin_https https://example.com:4438/root/MyGitRepo.git
error: src refspec https://example.com does not match any.
error: failed to push some refs to 'https://example.com:4438/root/MyGitRepo.git'
答案

问题是客户端上的密钥损坏 - 在Gitlab服务器上创建了新密钥/证书并替换了公钥。

以上是关于GitLab SSH要求输入密码(未知密码)身份验证失败的主要内容,如果未能解决你的问题,请参考以下文章

推送到 gitlab 时要求输入密码?

gitlab ssh-key 不生效问题,ssh push需要密码

gitlab的ssh登录密码没有怎么用

TortoiseGit尝试推送时要求我输入密码

gitlab配置ssh key后,还是需要输入密码,git clone http可以。

使用 ssh 密钥连接到 gitlab 项目