如何解决使用与Windows主机共享的存储库,在“ git fetch”上的Ubuntu VM上突然获得“权限被拒绝公钥”
我有一台Windows 10笔记本电脑。我在该笔记本电脑上运行了Ubuntu 18.04 VM。我在笔记本电脑上有几十个git存储库,其中远程是我们的Intranet BitBucket实例。我通过使用共享文件夹在Linux VM上引用了完全相同的存储库。这个设置已经运行了好一阵子了。我可以在Windows主机或Linux VM上执行所有相同的git操作,并且它们都可以正常工作,并且对这些操作的任何更改都会反映在其他OS上。
所有这些存储库均使用ssh克隆,并在BitBucket服务器中注册了密钥对。再次,这种方法运行了很长时间。
就在今天,我试图在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.
我从外壳以及Eclipse EGit进行了测试,结果相同。
然后我回到Windows主机,回到相同的存储库(请记住,我使用VM上的共享文件夹指向相同的存储库),并且做了同样的事情,并且运行良好。
最近几个月,我们的防火墙团队对我们的防火墙进行了一些更改,并且他们并不倾向于宣布更改,所以这是未知的。
我不确定我可以得到什么信息来诊断这一点。
更新:
设置GIT_SSH_COMMAND="ssh -vvv"
非常有用。这告诉我:
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.
最长时间以来,我在〜/ .ssh中的密钥对分别为“ id_rsa”和“ id_rsa.pub”。这是在寻找“ dsa”,而不是“ rsa”。我在网上看到一些关于应该使用哪个的争论,但我认为rsa对此仍然有效。目前尚不清楚该怎么办。
更新:
当我添加“ IdentityFile”时,它仍然无法正常工作,但是它显然注意到了新设置,并且做了一些不同的事情。现在,当我比较带有和不带有该设置的文本输出时,我看到即使没有“ IdentityFile”设置,它仍在查找“ id_rsa”文件,我只是没有注意到它。
我想以下省略的输出显示了在不使用新设置和使用新设置的情况下,详细的“ git fetch”输出的区别:
*** 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 ----
解决方法
感觉不确定性太大,无法给出准确的答案。您是否尝试通过运行带有详细输出的ssh来获取额外的调试信息?它可以暗示到底是什么问题:
尝试一下:
GIT_SSH_COMMAND="ssh -vvv" git clone or git fetch
更新:
好的,所以ssh冗长的输出告诉它确实尝试了几个密钥,但是没有找到任何密钥,因此无法对您进行身份验证。
.ssh / config中是否有任何内容?我通常将哪个密钥与哪个存储库一起使用。例如,在我的机器上,我有一个这样的条目:
$ cat .ssh/config
Host gitlab.com
Hostname gitlab.com
User git
IdentityFile ~/.ssh/id_rsa-gitlab
它告诉ssh使用此确切密钥进行身份验证。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。