[英]Suddenly getting “Permission denied (publickey)” on Ubuntu VM on “git fetch” using repository shared with Windows host
I have a Windows 10 laptop.我有一台 Windows 10 笔记本电脑。 I have an Ubuntu 18.04 VM running on that laptop.
我在那台笔记本电脑上运行了一个 Ubuntu 18.04 VM。 I have a few dozen git repositories on the laptop with the remote being our intranet BitBucket instance.
我在笔记本电脑上有几十个 git 存储库,远程是我们的 Intranet BitBucket 实例。 I reference the exact same repositories on the Linux VM by using shared folders.
我使用共享文件夹在 Linux VM 上引用了完全相同的存储库。 This setup has worked fine for quite a while.
这个设置已经运行了很长一段时间。 I can do all the same git operations on either the Windows host or the Linux VM, and they all work fine, and any changes from those operations are reflected on the other OS.
我可以在 Windows 主机或 Linux VM 上执行所有相同的 git 操作,并且它们都可以正常工作,并且这些操作的任何更改都会反映在其他操作系统上。
All of these repositories are cloned using ssh, with a keypair registered in the BitBucket server.所有这些存储库都使用 ssh 克隆,并在 BitBucket 服务器中注册了密钥对。 Again, this has worked fine for a long time.
同样,这在很长一段时间内都运行良好。
Just today, I tried to do some operations on the Linux VM, like "git fetch", and it's failing like this:就在今天,我尝试在 Linux VM 上进行一些操作,例如“git fetch”,但失败如下:
git@.....com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I tested this from the shell, and also from Eclipse EGit, with the same result.我从 shell 和 Eclipse EGit 测试了这个,结果相同。
I then went back to the Windows host, to the same repository (remember I use shared folders on the VM to point to the same repositories), and did the same thing, and it works perfectly fine.然后我回到 Windows 主机,到同一个存储库(请记住,我使用 VM 上的共享文件夹指向相同的存储库),并做了同样的事情,它工作得很好。
Our firewall team has made some changes to our firewall in recent months, and they don't tend to announce changes, so that's an unknown.我们的防火墙团队在最近几个月对我们的防火墙进行了一些更改,而且他们不倾向于宣布更改,所以这是一个未知数。
I'm not sure what information I can get to diagnose this.我不确定我能得到什么信息来诊断这个。
Update :更新:
Setting GIT_SSH_COMMAND="ssh -vvv"
is very informative.设置
GIT_SSH_COMMAND="ssh -vvv"
非常有用。 This tells me:这告诉我:
debug1: Offering public key: RSA SHA256:...
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug1: Trying private key: <myhome>/.ssh/id_dsa
debug3: no such identity: <myhome>/.ssh/id_dsa: No such file or directory
debug1: Trying private key: <myhome>/.ssh/id_ecdsa
debug3: no such identity: <myhome>/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: <myhome>/.ssh/id_ed25519
debug3: no such identity: <myhome>/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
For the longest time, I've had my key pairs in ~/.ssh as "id_rsa" and "id_rsa.pub".很长一段时间以来,我的密钥对在 ~/.ssh 中作为“id_rsa”和“id_rsa.pub”。 This is looking for "dsa", not "rsa".
这是在寻找“dsa”,而不是“rsa”。 I see some arguments on the net about which should be used, but I would think that rsa is still valid for this.
我在网上看到一些 arguments 应该使用哪个,但我认为 rsa 对此仍然有效。 It's not clear what should be done here.
目前还不清楚这里应该做什么。
Update :更新:
When I added "IdentityFile", it still didn't work, but it clearly noticed the new setting and did something different.当我添加“IdentityFile”时,它仍然不起作用,但它清楚地注意到了新设置并做了一些不同的事情。 Now when I'm comparing the text output both with and without that setting, I see that even without the "IdentityFile" setting, it was still finding the "id_rsa" file, I just didn't notice it.
现在,当我比较带有和不带有该设置的文本 output 时,我发现即使没有“IdentityFile”设置,它仍然在找到“id_rsa”文件,我只是没有注意到它。
I guess the following elided output shows the difference in the verbose "git fetch" output both without and with the new setting:我猜以下省略的 output 显示了详细的“git fetch” output 没有和使用新设置的区别:
*** withoutidentity.txt 2020-08-13 06:29:56.662638000 -0700
--- withidentity.txt 2020-08-13 06:30:10.786638000 -0700
***************
*** 10,27 ****
debug1: identity file <myhome>/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file <myhome>/.ssh/id_rsa-cert type -1
- debug1: key_load_public: No such file or directory
- debug1: identity file <myhome>/.ssh/id_dsa type -1
- debug1: key_load_public: No such file or directory
- debug1: identity file <myhome>/.ssh/id_dsa-cert type -1
- debug1: key_load_public: No such file or directory
- debug1: identity file <myhome>/.ssh/id_ecdsa type -1
- debug1: key_load_public: No such file or directory
- debug1: identity file <myhome>/.ssh/id_ecdsa-cert type -1
- debug1: key_load_public: No such file or directory
- debug1: identity file <myhome>/.ssh/id_ed25519 type -1
- debug1: key_load_public: No such file or directory
- debug1: identity file <myhome>/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: Remote protocol version 2.0, remote software version APACHE-SSHD-2.3.0
debug1: no match: APACHE-SSHD-2.3.0
--- 10,15 ----
***************
*** 90,100 ****
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
! debug2: key: <myhome>/.ssh/id_rsa (0x55b82d8f2390), agent
! debug2: key: davmichaelkarr@gmail.com (0x55b82d8f7c50), agent
! debug2: key: <myhome>/.ssh/id_dsa ((nil))
! debug2: key: <myhome>/.ssh/id_ecdsa ((nil))
! debug2: key: <myhome>/.ssh/id_ed25519 ((nil))
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
--- 78,85 ----
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
! debug2: key: <myhome>/.ssh/id_rsa (0x562f96fec330), explicit, agent
! debug2: key: davmichaelkarr@gmail.com (0x562f96ff1b30), agent
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
***************
*** 123,134 ****
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
- debug1: Trying private key: <myhome>/.ssh/id_dsa
- debug3: no such identity: <myhome>/.ssh/id_dsa: No such file or directory
- debug1: Trying private key: <myhome>/.ssh/id_ecdsa
- debug3: no such identity: <myhome>/.ssh/id_ecdsa: No such file or directory
- debug1: Trying private key: <myhome>/.ssh/id_ed25519
- debug3: no such identity: <myhome>/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
git@codecloud.web.att.com: Permission denied (publickey).
--- 108,113 ----
It feels like there is too much uncertainty to give a precise answer.感觉不确定性太多,无法给出准确的答案。 Did you try to get extra debug information by running ssh with verbose output?
您是否尝试通过运行带有详细 output 的 ssh 来获取额外的调试信息? It could hint what exactly is wrong:
它可能暗示到底出了什么问题:
Try this:尝试这个:
GIT_SSH_COMMAND="ssh -vvv" git clone or git fetch
Update:更新:
Alright, so the ssh verbose output tells that it did try a couple of keys however none of them have been found and so it is unable to authenticate you.好的,所以 ssh 详细 output 告诉它它确实尝试了几个密钥,但是没有找到它们,因此无法验证您的身份。
Do you have anything in your.ssh/config?你的 .ssh/config 中有什么东西吗? I usually put there which key shall be used with which repository.
我通常将哪个密钥与哪个存储库一起使用。 For example on my machine I have a such entry:
例如在我的机器上,我有一个这样的条目:
$ cat .ssh/config
Host gitlab.com
Hostname gitlab.com
User git
IdentityFile ~/.ssh/id_rsa-gitlab
It tells ssh to use this exact key for authentication.它告诉 ssh 使用这个确切的密钥进行身份验证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.