天天看點

gitlab項目遷移後,克隆至本地出現問題

Cloning into 'autotest_fe2'...
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@       WARNING: POSSIBLE DNS SPOOFING DETECTED!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The RSA host key for git.n.xxx.com has changed,
and the key for the corresponding IP address 10.108.000.000
has a different value. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
Offending key for IP in /Users/wanggonggege/.ssh/known_hosts:6
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:wsa13STT4ruBMRh72sRRyTdY/zjtwBFu2rGA5mdosKY.
Please contact your system administrator.
Add correct host key in /Users/wanggonggege/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/wanggonggege/.ssh/known_hosts:11
RSA host key for git.n.xxx.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.

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

業務場景:把負責的項目auto從一個老git遷移到新git,在新git上克隆項目代碼到本地時,報錯如上,無法正常克隆。

報錯解析:

警告:檢測到可能産生DNS欺騙

項目git上的RSA主機key已經被修改了。這個key和相應的ip位址10.108.000.000 是不同的值。這意味着DNS欺騙已經發生了或者是你的主機IP位址和主機key此時已經改變了。對于ip的攻擊型key在你的本地目錄/Users/wanggonggege/.ssh/known_hosts:6。

警告:遠端主機身份識别已經改變。

一些人可能現在正在監聽你(中間人攻擊)!也可能是主機key被改變了。

緻命的:不能閱讀遠端倉庫。

請确認你擁有正确的權限,并且倉庫已存在。      

用人話來說就是,這是一種保護你的機制,因為你的ssh會自動記錄你通路的所有的key,并且寫入~/.ssh/known_hosts中。每次通路的時候他會對照這個檔案的key表,key不同會發警告。項目遷移了,兩個key必然不同,是以會報錯。

解決:删除對應ip的rsa資訊就行了。

指令行操作如下:

ssh-keygen -R xxx.xxx.xxx.xxx (伺服器ip位址)      

開始我的表演:

wanggonggegedeMacBook-Air:autoTest_fe2 wanggonggege$ ssh-keygen -R 10.108.000.000
# Host 10.108.000.000 found: line 6
/Users/wanggonggege/.ssh/known_hosts updated.
Original contents retained as /Users/wanggonggege/.ssh/known_hosts.old      

前後對比ssh/known_hosts确實發現  10.108.000.000的記錄已經沒有了。

可是,貌似是删除的不幹淨,然後我git clone并不好用,依然報錯如上。

我這小暴脾氣能忍它麼。

直接清空了~/.ssh/known_hosts,當然提前備份了一下,怕出現啥子鬼問題。

清空之後再次git clone,萬事大吉。