使用与Windows主机共享的存储库,在“ git fetch”上的Ubuntu VM上突然获得“权限被拒绝公钥”

如何解决使用与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 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-