gitlab使用SSH无法下载

问题描述:

git下载gitlab仓库中代码,出现使用http能使用,但是ssh下载一直需要报输入密码,密码也一直输入不正确问题。


[root@web-m data]# git clone ssh://git@gitlab.lixinkuan.com:22022/lxk/core.git
Cloning into 'core'...
git@gitlab.lixinkuan.com's password: 
Permission denied, please try again.
git@gitlab.lixinkuan.com's password: 
Permission denied, please try again.
git@gitlab.lixinkuan.com's password: 
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
fatal: Could not read from remote repository.
 
Please make sure you have the correct access rights
and the repository exists.

解决办法:

1,创建ssh-key

输入ssk-keygen之后一直按enter,使用默认参数

/.ssh$ ssh-keygen
Enter file in which to save the key (/home/airgens/.ssh/id_rsa):

2,将公钥加载进去

ssh-add ~/.ssh/id_rsa

ssh-add   ~/.ssh/id_rsa

上面操作如果出现错误:

Agent admitted failure to sign using the key

则需要先运行

ssh-agent bash --login -i

3,需要在gitlab管理页面添加ssh-key

cat id_rsa.pub  将内容拷贝到如下位置 

 4,验证OK

xxg@ubuntu:~/.ssh$ git clone git@192.168.xx.61:cszsfs/Android11.0.git
Cloning into 'Android11.0'...
^Cmote: Enumerating objects: 713441

分析:

该问题是由于本地ssh生成的秘钥未添加到ssh代理中导致


版权声明:本文为wfjdemmye原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。