菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
251
0

git秘钥问题解析及gitlab配置(Please make sure you have the correct access rights and the repository exists)

原创
05/13 14:22
阅读数 85986

1、背景描述

前端开发从进项目,代码有几周没提交了,公司管理员给分配了gitlab的权限,就帮他弄下,结果一直报以下错误:

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


git clone git@gitlab.cpirhzl.com:ruanjianlaowang/web.git c:\Users\软件老王\Desktop\web --progress
Host key verification failed.
fatal: Could not read from remote repository.

从报错信息看,要么远程仓库地址不对,要么是没有权限,重新生成秘钥了和检查地址了好多次,就是不行,弄的有点怀疑人生了,最后突然发现问题所在,记录下,希望能帮到朋友们。

2、解决方案

2.1 首先下载下git客户端

地址:

https://git-scm.com/download/win

下载后exe文件,直接next、next到最后一步,全部默认安装就好了。

2.2 生成ssh秘钥

(1)## 生成ssh密钥
ssh-keygen -t rsa -C <your email>
例如:ssh-keygen -t rsa -C ruanjianlaowang@163.com

(2)# 一路回车保存为默认名字
Enter file in which to save the key (/home/raunjianlaowang/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:


(3)## 会自动生成两个文件
## 私钥文件:id_rsa 公钥文件:id_rsa.pub

# windows
C:\Users\登陆用户名称\.ssh

例如老王的:
C:\Users\Administrator\.ssh
linux
/home/ruanjianlaowang/.ssh

2.3 打开公钥文件id_rsa.pub

以ssh-rsa 开头,直接全部复制粘贴:

2.4 复制到gitlab账户中的

登陆账户右上角的设置->ssh秘钥->复制公钥到空白框中添加即可。

2.5 其他

项目主要是在idea中使用的,以下这一步刚开始我们没做,不过在找问题的有朋友提到可能是这个问题,也随便做了做,不过以前记得是没有这样做的。

# 检查项目/全局 git配置
git config --global --list
# 修改git账号为远程仓库账号密码
git config --global user.name <your name>
git config --global user.email <your email>

2.6 还是说重点吧,错误怎么解决的

为什么很简答的操作,反复确认了还是报:Please make sure you have the correct access rights and the repository exists呢?

Enter file in which to save the key (/home/raunjianlaowang/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:

问题出在了这一步了,Enter passphrase,这里输入了账户密码,导致在idea中一直报没有权限,但是idea却没有提示要录入密码,后面通过git命令拉取的时候,弹出让输入密码,输入居然好了,才发现这里要直接回车,不能输入密码,否则idea中就无法拉取远程仓库的代码。

Enter passphrase要直接回车,不能录入密码!

Enter passphrase要直接回车,不能录入密码!

Enter passphrase要直接回车,不能录入密码!


更多信息请关注公众号:「软件老王」,关注不迷路,软件老王和他的IT朋友们,分享一些他们的技术见解和生活故事。

发表评论

0/200
251 点赞
0 评论
收藏
为你推荐 换一批