一日,同事安裝了2.33.1版本的git,生成密鑰、gitlab賬戶綁定pubkey一氣呵成后,發(fā)現(xiàn)pull代碼時(shí)報(bào)錯(cuò):
$ git pull
Unable to negotiate with 12.34.56.78 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss
fatal: Could not read from remote repository.
而使用著2.32.0版本的我一切正常。
重裝2.32版本后的確一切問題解決,但是為何2.33之后會(huì)出現(xiàn)這種問題?
在git-bash中使用ssh -V查看openssh版本,使用的版本是8.8p1
OpenSSH_8.8p1, OpenSSL 1.1.1l 24 Aug 2021
而2.32使用的是8.5p1
經(jīng)過網(wǎng)上排查,發(fā)現(xiàn)8.8p1版本開始,客戶端默認(rèn)禁用了ssh-rsa,而我們的gitlab目前只支持ssh-rsa,所以只能在本地開啟ssh-rsa的支持:
在本機(jī)~/.ssh/目錄添加config文件,寫入配置:
Host * (全部開啟,也可針對(duì)性調(diào)整,此處請(qǐng)刪除)
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa
保存,再嘗試git pull,一切正常