首页 > 解决方案 > 克隆 GitLab 存储库时权限被拒绝?

问题描述

我在我的 Ubuntu 18.04 上安装了 GitLab 作为 VM。我添加了我的 SSH 密钥。当我尝试克隆时

git clone git@192.168.50.10:johnholmes/helloworld2.git
Cloning into 'helloworld2'...
The authenticity of host '192.168.50.10 (192.168.50.10)' can't be established.
ECDSA key fingerprint is SHA256:f5ZhPsTYy3qV4aaRuct7ycOgB/CuC3MbD8QAgqYYp2A.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.50.10' (ECDSA) to the list of known hosts.
git@192.168.50.10's password: 
Permission denied, please try again.

或者我应该克隆到vagrant@gitlab:~$

我想克隆空仓库,添加文件并学习 GitLab。

标签: gitgitlab

解决方案


问题不在于您要克隆它的位置。这是您在 git 服务器上的访问权限。

选项 1 - 使用 Git GUI

  1. 转到桌面上的 Git GUI -> 帮助 -> 显示 SSH 密钥并复制公钥(如果不可用则生成)
  2. 将 SSH 公钥加载到您的 Gitlab 服务器。转到设置-> SSH 密钥并粘贴您复制的内容
  3. 检查您是否有权访问您尝试在 Gitlab 上克隆的存储库
  4. 再次尝试克隆

选项 2 - 仅使用命令行

  1. 按照本指南https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key生成 SSH 密钥并获取您的公钥
  2. 按照选项 1 中的步骤 1-4

推荐阅读