git - 克隆 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。
解决方案
问题不在于您要克隆它的位置。这是您在 git 服务器上的访问权限。
选项 1 - 使用 Git GUI
- 转到桌面上的 Git GUI -> 帮助 -> 显示 SSH 密钥并复制公钥(如果不可用则生成)
- 将 SSH 公钥加载到您的 Gitlab 服务器。转到设置-> SSH 密钥并粘贴您复制的内容
- 检查您是否有权访问您尝试在 Gitlab 上克隆的存储库
- 再次尝试克隆
选项 2 - 仅使用命令行
- 按照本指南https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key生成 SSH 密钥并获取您的公钥
- 按照选项 1 中的步骤 1-4
推荐阅读
- c# - 从代码添加响应标头时出现问题
- python - 在自定义用户的配置文件中发现不需要的随机值
- c++ - 用 X C++ 练习替换字符串中的字符
- python - 单个类中的 Python 函数调用
- azure - Azure Function 部署缓慢
- javascript - 如何在 ionic 3 中实现进度条?
- python - python 中的 os.listdir() 不显示目录的所有文件。它跳过了其中的几个
- c# - Xamarin Forms - 识别设备是否以纵向模式锁定
- javascript - 画布中对象之间的碰撞检查始终为正
- sql - Amazon Redshift:连接列内容略有不同的两列