WSL 上的 Git 通过 SSH 到 Azure DevOps 失败,并显示 "Permission denied (password,publickey)."

标签 git azure ssh devops windows-subsystem-for-linux

我正在尝试克隆我们的一个存储库,但总是提示我输入 {myco}@vs-ssh.visualstudio.com 的密码。我的环境是WSL,Pengwin(本质上是Debian),最新的git。 ~/.ssh 的内容:

-rw------- 1 val val  738 Dec  2 21:09 authorized_keys
-rwx------ 1 val val  562 Mar 28 20:21 config*
-r-------- 1 val val  399 Mar 28 17:42 id_ed25519
-r-------- 1 val val   93 Mar 28 17:42 id_ed25519.pub
-r-------- 1 val val 1.8K Mar 28 17:42 id_rsa
-r-------- 1 val val 1.8K Mar 28 20:04 id_rsa_ado
-r-------- 1 val val  393 Mar 28 20:04 id_rsa_ado.pub
-r-------- 1 val val  394 Mar 28 17:42 id_rsa.pub
-rw-r--r-- 1 val val 3.9K Mar 10 11:20 known_hosts

在 Azure DevOps 上:

Name id_rsa_ado.pub
Fingerprint 39:03:4b:6e:4b:3b:92:6c:c9:c0:f5:c2:b6:bc:8c:da

在我的机器上:

❯ ssh-keygen -l -E md5 -f ~/.ssh/id_rsa_ado
2048 MD5:39:03:4b:6e:4b:3b:92:6c:c9:c0:f5:c2:b6:bc:8c:da Val Melamed (RSA)

~/.ssh/config 的内容:

CanonicalizeHostname yes

Host github.com
  HostName github.com
  IdentityFile ~/.ssh/id_ed25519

Host vs-ssh.visualstudio.com
  HostName vs-ssh.visualstudio.com
  User {myco}
  IdentityFile ~/.ssh/id_rsa_ado

Host vs-ssh.visualstudio.com
  HostName vs-ssh.visualstudio.com
  User {myco}
  IdentityFile ~/.ssh/id_rsa_ado

Host *
  User git
  ForwardAgent yes
  AddKeysToAgent yes
  LogLevel FATAL
  ServerAliveInterval 300
  TCPKeepAlive no
  IdentitiesOnly yes

请注意,上面对于用户,我尝试了“git”和“{myco}”,但结果相同。

SSH 测试通过:

❯ ssh -Tv {myco}@vs-ssh.visualstudio.com
OpenSSH_8.4p1 Debian-5, OpenSSL 1.1.1n  15 Mar 2022
debug1: Reading configuration data /home/val/.ssh/config
debug1: /home/val/.ssh/config line 7: Applying options for vs-ssh.visualstudio.com
debug1: /home/val/.ssh/config line 12: Applying options for vs-ssh.visualstudio.com
debug1: /home/val/.ssh/config line 17: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: hostname canonicalisation enabled, will re-parse configuration
debug1: re-parsing configuration
debug1: Reading configuration data /home/val/.ssh/config
debug1: /home/val/.ssh/config line 7: Applying options for vs-ssh.visualstudio.com
debug1: /home/val/.ssh/config line 12: Applying options for vs-ssh.visualstudio.com
debug1: /home/val/.ssh/config line 17: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to vs-ssh.visualstudio.com [20.41.6.12] port 22.
debug1: Connection established.
debug1: identity file /home/val/.ssh/id_rsa_ado type 0
debug1: identity file /home/val/.ssh/id_rsa_ado-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.4p1 Debian-5
debug1: Remote protocol version 2.0, remote software version SSHBlackbox.10
debug1: no match: SSHBlackbox.10
debug1: Authenticating to vs-ssh.visualstudio.com:22 as 'thycotic'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<8192<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:ohD8VZEXGWo6Ez8GSEJQ9WpafgLFsOfLOtGGQCQo6Og
debug1: Host 'vs-ssh.visualstudio.com' is known and matches the RSA host key.
debug1: Found key in /home/val/.ssh/known_hosts:12
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 4294967296 blocks
debug1: Will attempt key: /home/val/.ssh/id_rsa_ado RSA SHA256:lxYw6Y7pOlaF68Hwovn7xiQrT7DKZjEuZFR3AnlZW7Q explicit agent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: password,publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/val/.ssh/id_rsa_ado RSA SHA256:lxYw6Y7pOlaF68Hwovn7xiQrT7DKZjEuZFR3AnlZW7Q explicit agent
debug1: Server accepts key: /home/val/.ssh/id_rsa_ado RSA SHA256:lxYw6Y7pOlaF68Hwovn7xiQrT7DKZjEuZFR3AnlZW7Q explicit agent
debug1: Authentication succeeded (publickey).
Authenticated to vs-ssh.visualstudio.com ([20.41.6.12]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Requesting authentication agent forwarding.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
remote: Shell access is not supported.
shell request failed on channel 0

克隆失败:

❯ sudo git clone {myco}@vs-ssh.visualstudio.com:v3/{myco}/{project}/{repo}
Cloning into '{repo}'...
{myco}@vs-ssh.visualstudio.com's password:
Permission denied, please try again.
{myco}@vs-ssh.visualstudio.com's password:
Permission denied, please try again.
{myco}@vs-ssh.visualstudio.com's password:
{myco}@vs-ssh.visualstudio.com: Permission denied (password,publickey).
fatal: Could not read from remote repository.

{} 大括号中的内容当然是我的公司、项目和存储库的占位符。

所有这些都曾经有效,然后就因上述行为而停止了。尝试了很多事情,生成了一个新 key (上面),但没有骰子...有人看到我错过了什么或做错了什么吗?

最佳答案

我删除了 git clone 前面的 sudo 并修复了它。

关于WSL 上的 Git 通过 SSH 到 Azure DevOps 失败,并显示 "Permission denied (password,publickey).",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71655428/

相关文章:

c# - 无法以编程方式下载文件 (C#)

azure - 检查值是否不在 Application Insights 查询语言的列表中?

java - 公钥或私钥作为连接远程数据库的密码,ssh

git - 是否有 git gui 工具来检查和提交 cloud9 编辑器中的更改?

git - 时间跟踪+Git : measuring effort per commit

azure - awverify CNAME 未被选取

Git push over ssh 在 Windows 上失败,错误为 'the remote end hung up unexpectedly'

Gitignore:我应该提交更改吗?

git - 找到更改文件权限的提交

ssh - SSH空闲超时相关