【Git】ssh: Could not resolve hostname gitlab.123.com: Name or service not known

前一天可以拉取代码的slave机器,第二天就不能访问git了,,检查了公钥没有被重新生成,可key也在git项目上正常启用,那是咋回事呢,排查了一下,机器因为某些服务需要特殊配置所以直接调整了dns,导致域名无法识别。

执行git clone时出现权限错误:

# ssh: Could not resolve hostname gitlab.123.com: Name or service not known 
# fatal: Could not read from remote repository.
# Please make sure you have the correct access rightsand the repository exists.

检查本地公钥没有变化,git权限正常
使用ssh -vvv -p查看调试信息:

ssh -vvv git@gitlab.123.com -p 10123
# OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
# debug1: Reading configuration data /etc/ssh/ssh_config
# debug1: /etc/ssh/ssh_config line 58: Applying options for *
# debug2: resolving "gitlab.123.com" port 10123
# ssh: Could not resolve hostname gitlab.123.com: Name or service not known

ssh -vvv查看结果表示域名找不到,检查发现域名正常没有输入错误

随后ping域名发现果然是ping不通:

ping gitlab.123.com
# ping: gitlab.123.com: Name or service not known

查看dns服务配置:
发现做了特殊配置,但是因为特殊服务需要,不能修改dns服务,这个时候,只能用host方式绑定域名了

vim /etc/hosts
> 10.10.22.33  gitlab.123.com

绑定域名后再ping,正常通信,git clone 回复正常

ping gitlab.123.com
# PING gitlab.123.com ([10.10.22.33](10.10.22.33)) 56(84) bytes of data.
# 64 bytes from gitlab.123.com ([10.10.22.33](10.10.22.33)): icmp_seq=1 ttl=57 time=1.62 ms
# 64 bytes from gitlab.123.com ([10.10.22.33](10.10.22.33)): icmp_seq=2 ttl=57 time=1.58 ms
# 64 bytes from gitlab.123.com ([10.10.22.33](10.10.22.33)): icmp_seq=3 ttl=57 time=1.58 ms

这种方式虽然解决了问题,但是还是建议排查dns,不用本地的dns解析,因为一旦git服务器的ip发生变化,这种hosts的方式还要做调整。

原文链接:https://www.jianshu.com/p/e5636f0d591d
原文作者:M_GBO

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值