前一天可以拉取代碼的slave機(jī)器茄猫,第二天就不能訪問(wèn)git了狈蚤,困肩,檢查了公鑰沒(méi)有被重新生成,可key也在git項(xiàng)目上正常啟用脆侮,那是咋回事呢锌畸,排查了一下,機(jī)器因?yàn)槟承┓?wù)需要特殊配置所以直接調(diào)整了dns他嚷,導(dǎo)致域名無(wú)法識(shí)別蹋绽。
- 執(zhí)行
git clone
時(shí)出現(xiàn)權(quán)限錯(cuò)誤:
# 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.
- 檢查本地公鑰沒(méi)有變化,git權(quán)限正常
- 使用
ssh -vvv -p
查看調(diào)試信息:
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
查看結(jié)果表示域名找不到筋蓖,檢查發(fā)現(xiàn)域名正常沒(méi)有輸入錯(cuò)誤
- 隨后
ping
域名發(fā)現(xiàn)果然是ping不通:
ping gitlab.123.com
# ping: gitlab.123.com: Name or service not known
- 查看dns服務(wù)配置:
發(fā)現(xiàn)做了特殊配置卸耘,但是因?yàn)樘厥夥?wù)需要,不能修改dns服務(wù)粘咖,這個(gè)時(shí)候蚣抗,只能用host方式綁定域名了
vim /etc/hosts
> 10.10.22.33 gitlab.123.com
- 綁定域名后再
ping
,正常通信瓮下,git clone
回復(fù)正常
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
這種方式雖然解決了問(wèn)題翰铡,但是還是建議排查dns,不用本地的dns解析讽坏,因?yàn)橐坏ゞit服務(wù)器的ip發(fā)生變化锭魔,這種hosts的方式還要做調(diào)整。