【问题标题】:Git repo Access not working with access keysGit repo Access 无法使用访问密钥
【发布时间】:2021-07-28 16:54:34
【问题描述】:
  1. 我已经使用 ssh-keygen 命令为用户“devuser”生成了 ssh 密钥
  2. 生成私钥和公钥后,我已将公钥添加到项目的bitbucket中的Access Keys列表中
  3. 当我尝试从 bitbucket 克隆 repo 时,出现以下错误
git clone ssh://git@host.fqdn.net:6999/dev-project/test-repo.git
Cloning into 'test-repo'...
ssh: Could not resolve hostname /home/devuser/.ssh2/id_rsa_2048_b: Name or service not known
fatal: Could not read from remote repository.

请确保您拥有正确的访问权限 并且存储库存在。

当我为同一主机上的不同用户尝试相同的步骤时,对我来说效果很好。感谢任何指针

【问题讨论】:

  • 您的~/.ssh/config 文件中是否有任何内容(尤其是与host.fqdn.net 相关的条目)?
  • ssh -vT git@host.fqdn.net:6999 输出是什么?
  • OpenSSH_7.4p1,OpenSSL 1.0.2k-fips 2017 年 1 月 26 日调试 1:读取配置数据 /etc/ssh/ssh_config 调试 1:/etc/ssh/ssh_config 第 66 行:应用选项 * debug1:连接到 host.fqdn.net [53.124.43.134] 端口 22。debug1:连接到地址 53.124.43.134 端口 22:连接被拒绝 ssh:连接到主机 host.fqdn.net 端口 22:连接被拒绝

标签: linux git ssh version-control bitbucket


【解决方案1】:

要添加到larsks'comment,请尝试:

GIT_SSH_COMMAND='ssh -F /dev/null' git clone ssh://git@host.fqdn.net:6999/dev-project/test-repo.git

或者

GIT_SSH_COMMAND='ssh -F /dev/null -i /home/devuser/.ssh2/id_rsa_2048_b' \
git clone ssh://git@host.fqdn.net:6999/dev-project/test-repo.git

这将强制 SSH 连接到 ignore your ~/.ssh/config

  • 如果可行,请查看上述config 文件。
  • 如果不是,那么,如上所述,请查看 ssh -vT git@host.fqdn.net:6999 以了解 SSH 在与远程站点交互期间会考虑哪些本地文件。

【讨论】:

  • OpenSSH_7.4p1,OpenSSL 1.0.2k-fips 2017 年 1 月 26 日调试 1:读取配置数据 /etc/ssh/ssh_config 调试 1:/etc/ssh/ssh_config 第 66 行:应用选项 * debug1:连接到 host.fqdn.net [53.124.43.134] 端口 22。debug1:连接到地址 53.124.43.134 端口 22:连接被拒绝 ssh:连接到主机 host.fqdn.net 端口 22:连接被拒绝
  • 我为其他有效的用户得到了相同的输出
  • @user3539927 我刚刚编辑了答案:您可以将私钥添加到GIT_SSH_COMMAND,以进行测试吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-16
  • 2014-07-24
  • 2018-05-25
  • 2019-04-21
相关资源
最近更新 更多