gitlab ssh clone问题解决
公司搭建的gitlab,通过http协议可以clone:
[sisi@pre-srv24 gitlab]$ git clone http://gitlab.test.mycompany.com/dev_group/test_project1.git
Cloning into 'test_project1'...
Username for 'http://gitlab.test.mycompany.com': sisi
Password for 'http://sisi@gitlab.test.mycompany.com':
remote: Counting objects: 11, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 11 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (11/11), done.
但是用ssh clone就会失败
[sisi@pre-srv44 ssh]$ git clone git@gitlab.test.mycompany.com:dev_group/test_project1.git
Cloning into 'test_project1'...
The authenticity of host 'gitlab.test.mycompany.com (123.56.11.231)' can't be established.
RSA key fingerprint is 5d:62:8d:b7:d7:51:03:87:ea:65:ce:35:6c:ee:95:7a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitlab.test.mycompany.com,123.56.11.231' (RSA) to the list of known hosts.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
解决方案
(1)修改/etc/ssh/sshd_config文件
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
(2)改权限及公钥
#chmod 700 /root/.ssh
#chmod 644 /root/.ssh/authorized_keys
并把本地主机的pub公钥放到/root/.ssh/authorized_keys
(3)重启sshd
service restart
但是之后用ip测试连接成功,用域名则失败
[sisi@pre-srv44 ssh]$ ssh -T git@172.16.181.60
Welcome to GitLab, sisi!
[sisi@pre-srv44 ssh]$ ssh -T git@gitlab.test.mycompany.com
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
git clone的结果也是一样的
[sisi@pre-srv44 ssh]$ git clone git@gitlab.test.mycompany.com:dev_group/test_project1.git
Cloning into 'test_project1'...
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
[sisi@pre-srv44 ssh]$ git clone git@172.16.181.60:dev_group/test_project1.git
Cloning into 'test_project1'...
remote: Counting objects: 11, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 11 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (11/11), done.
[sisi@pre-srv44 ssh]$
用IP可以克隆,用域名还不行
那么问题在于域名是否正确解析为正确的ip
[sisi@pre-srv44 .ssh]$ host gitlab.test.mycompany.com
gitlab.test.mycompany.com has address 123.56.11.231
[sisi@pre-srv44 ssh]$ ping gitlab.test.mycompany.com
PING gitlab.test.mycompany.com (172.16.181.60) 56(84) bytes of dat
不同方式获取的IP不一致,是导致ssh用域名访问不行的原因
而执行git clone时连接的服务器地址放在.ssh/known_hosts中,从其中可以看出域名被解析成123.56.11.231,
即与host命令查到的ip一致,都是错误的
解决方案:
(1)删除 .ssh/known_hosts中错误的域名ip记录
(2)在/etc/hosts增加域名与正确ip的对应
[sisi@pre-srv44 .ssh]$ sudo vi /etc/hosts
增加一行
172.16.181.60 gitlab.test.mycompany.com
再测试成功如下:
[sisi@pre-srv44 ssh]$ git clone git@gitlab.test.mycompany.com:dev_group/test_project1.git
Cloning into 'test_project1'...
The authenticity of host 'gitlab.test.mycompany.com (172.16.181.60)' can't be established.
RSA key fingerprint is ba:ec:d0:b3:b3:1e:39:10:fc:b2:ac:3d:41:ff:d1:50.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitlab.test.mycompany.com,172.16.181.60' (RSA) to the list of known hosts.
remote: Counting objects: 11, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 11 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (11/11), done.
[sisi@pre-srv44 ssh]$ ls
test_project1
gitlab ssh clone问题解决的更多相关文章
- HTTPS clone !== SSH clone
HTTPS clone !== SSH clone https clone bug SSH clone OK testing SSH key https://www.cnblogs.com/xgqfr ...
- 【docker】【Gitlab】gitlab中clone项目时,IP地址是一串数字(内网Gitlab的IP地址不正确)的问题解决
首次在内网搭建Gitlab环境,在成功后在Gitlab上新建了一个项目. 然而在IDEA上clone项目时发现,项目地址如下: git@0096ce63c43f:root/jump.git 或者这样 ...
- window下 配置gitlab ssh非端口22端口
git config --global user.name "jack" git config --global user.email "jackluo@xxx.com& ...
- 关于gitlab的一个问题解决
这两天折腾一个关于gitlab的问题,搞得比较焦头烂额.不过经过折腾,最终还是成功了. 当面对着一个问题,并且看到还没被解决的时候,感觉很不舒服: 努力折腾之后,解决之后,也会身体轻松.或许工程师天生 ...
- gitlab之四: gitlab ssh key 配置
参考: https://www.cnblogs.com/hafiz/p/8146324.html 1. gitlab的右上角. 用户下拉菜单--->setting>ssh密钥,将公钥 ...
- intellij idea 配置gitlab ssh key
1 安装git,登录官网https://www.git-scm.com/download/ ,选择相应系统版本,下载后安装好. 公司网慢的可以用第三方的软件管家下载. 2 打开git bash,不需要 ...
- 创建gitlab ssh 密钥
SSH代表用于管理网络,操作系统和配置的Secure Shell或Secure Socket Shell,并且每次都不需要使用用户名和密码即可验证GitLab服务器. 您可以设置SSH密钥以提供计算机 ...
- windows下如何通过git bash获取gitlab ssh公钥
Gitlab1. 安装git,从程序目录打开 "Git Bash" 2. 键入命令:ssh-keygen -t rsa -C "email@email.com" ...
- 登陆跳板机每天只输入一次token的方法——ssh clone session
自从跳板机升级后,无所不在的token让小PE很是恼火,于是有了这篇文章@_@ Linux or Mac篇 在Fedora或者Mac下很简单,修改~/.ssh/config文件,没有的话,就新建一个( ...
随机推荐
- 九度OJ-1001-A+B矩阵-有些小技巧
题目1001:A+B for Matrices 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:22974 解决:9099 题目描述: This time, you are supposed ...
- C#正则表达式语法教程
C#语法之正则 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- 心分享.心创新!助力 ...
- 简易计算器的java实现
伪代码 public class MainTestwei { 定义两个数组,List<Double> number和 List<Character>calculation分别用 ...
- HDU 1087:Super Jumping! Jumping! Jumping!(LIS)
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- root用户登录mysql后新建用户提示1045错误
执行以下命令查看root权限 show grants for 'root'@'localhost'; 如果没有显示with grant option,说明是root没有拥有新建授权用户的权限(为什么会 ...
- Spring定时器corn表达式详解
1.结构 Spring定时器corn表达式详解 2.各字段的含义 字段 允许值 允许的特殊字符 秒 0~59 - * / 分 0~59 - * / 小时 0~23 - * / 日期 1~31 - * ...
- 存储-实例-ibm v3700
raid5总容量计算(n-1)*最小盘容量 RAID0:N块盘组成,逻辑容量为N块盘容量之和:RAID1:两块盘组成,逻辑容量为一块盘容量:RAID3:N+1块盘组成,逻辑容量为N块盘容量之和:RAI ...
- Linux 日志分析工具之awstats
一.awstats 是什么 官方网站:AWStats is a free powerful and featureful tool that generates advanced web, strea ...
- c++内存泄漏原因及解决办法(智能指针)
内存泄漏 由于疏忽或错误造成程序未能释放已经不再使用的内存的情况.内存泄漏并非指内存在物理上的消失,而是应用程序分配某段内存后,由于设计错误,失去了对该段内存的控制,因而造成了内存的浪费. 内存泄露的 ...
- 第一个项目:Python pygame——外星人大战(心得)
2018年12月,作为一个大学专业是物联网工程,毕业后在一家石油行业国企干了近三年,但内心依然有着一颗技术之心的我,通过一次偶然的机会(也许并不偶然),接触到了python.当时抱着玩一玩的心态开始通 ...