【问题标题】:Gitlab deploy keys configured but still doesn't grant accessGitlab部署密钥已配置但仍不授予访问权限
【发布时间】:2021-03-11 19:22:07
【问题描述】:

我刚刚为 Gitlab 配置了一个部署密钥,这样它就不会每次都要求输入用户名和密码——但是在拉取时,它仍然失败并出现以下错误:

git@gitlab.com: Permission denied (publickey, keyboard-interactive).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

到目前为止我所做的是:

  1. 生成了可以在~/.ssh/下找到的SSH密钥
  2. 复制并粘贴 id_rsa.pub 到 Gitlab 部署密钥部分
  3. 将密钥添加到带有ssh-add ~/.ssh/id_rsa 的SSH 注册表
  4. ~/.ssh下设置一个配置文件,内容如下:
    Host gitlab.co
    RSAAuthentication yes
    IdentityFile ~/.ssh/id_rsa
    
  5. git remote 从使用 HTTPS 的@更改为使用 SSH 的。

我在 Google 和 StackOverflow 上都搜索了可能的解决方案,但没有找到任何类似的讨论。有什么想法我可能会遗漏吗?

【问题讨论】:

    标签: git ssh deployment gitlab


    【解决方案1】:

    我使用sudo 执行git pull,导致服务器尝试使用 sudo 用户的 SSH 密钥进行身份验证。

    我通过将.git 目录的所有者更改为我的登录用户来修复它,这意味着这个命令:

    sudo chown -R ubuntu:ubuntu .git
    

    之后,一切正常。

    我相信这是一种常见的情况,现在我很惊讶我找不到有关此的更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-09
      • 2017-11-30
      • 2018-12-20
      • 2014-09-27
      相关资源
      最近更新 更多