子模块:权限被拒绝(公钥)

时间:2018-12-18 22:38:10

标签: git bitbucket bitbucket-server bitbucket-cloud

我们的git仓库有一个奇怪的问题。我们引用了两个子模块(不确定是否很重要:一个引起麻烦的模块位于bitbucket云上,而repo和另一个子模块位于同一bitbucket服务器实例上)

如果有人想重新签出存储库,则会收到以下错误:

Cloning into local/path…
Warning: Permanently added the RSA host key for IP address 
xx.xxx.xxx.xxx to the list of known hosts.

Permission denied (publickey).
fatal: Could not read from remote repository.

我期望的是无法正确设置ssh键,但奇怪的是:如果我们通过文件系统手动复制子模块的内容,从那一刻起一切正常,然后进行拉动,切换子模块中的分支等工作正常。

这使我假设某些git设置位于我要复制的子模块文件夹中,但实际上只有两个git文件: gitignore(不会忽略任何特殊/可疑的东西)和一个仅包含 gitdir:../../../。git / modules / path / to / submodule

这应该与权限无关,所以谁能解释为什么手动复制解决了权限问题?

4 个答案:

答案 0 :(得分:1)

我最终删除了子模块,因为似乎还有其他奇怪的事情。例如,由bitbucket显示的克隆链接显示为“ git clone git@bitbucket.org:company / repo-name.git,它不能被sourcetree正确识别。.冒号似乎放错了位置,我们的其他存储库指定了端口,然后到回购协议的路径仅带有斜线。因此,无论回购协议有什么问题,它在某些地方似乎都是错误的,因此我们将其完全淘汰了

答案 1 :(得分:0)

将密钥添加到本地Bitbucket Server实例将更新该Bitbucket Server实例。但是,它根本不会对Bitbucket Cloud做任何事情。

听起来您在这里有两个选择:

  1. 让用户创建Bitbucket Cloud帐户,然后将其SSH密钥与这些帐户相关联。
  2. 将HTTPS用于远程子模块。

答案 2 :(得分:0)

当我尝试在Mac上克隆子模块时,我遇到了相同的错误

git submodule update --init
Cloning into '**** local repo *****'...
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.

当我将ssh密钥设置为本地计算机和bitbucket帐户时,它解决了。

参考:https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html

答案 3 :(得分:0)

确保您的子模块使用用户 git (git@bitbucket.org),而不是当前用户。我通过在 ~/.ssh/config 中添加 bitbucket.org 的配置解决了这个问题:

host bitbucket.org
    user git