場景:
本地執行 ssh-keygen -t rsa -C “郵箱”后將~/.ssh/id_rsa.pub的內容放到gerrit上,windows系統上打開git bash使用ssh的防止執行git clone ssh://xx@gerritip:29418/pro_test的方式下載代碼。
這個問題真的是頭大了很久的一個問題。不知道從哪天開始,后面新來的同事使用windows從gerrit下載代碼一直報錯,但是之前的用windows的同事是可以正常下代碼的。
分析:
(1)剛開始懷疑是git bash版本的問題,給了我的正常的git bash版本給新同事,還是不能下代碼,
(2)然后懷疑是生成的ssh key有問題,可是新同事放到自己的github上也可以正常下代碼,
(3)我用linux進行代碼下載也是沒問題的,最后都不知道該懷疑哪里了。
曙光:
百度上搜了好幾天,看到的回答沒有一個可以解決我的問題,結果翻了個牆,google到的第一個回答就解決了我的問題!!!
報錯如下:
$ git clone ssh://az@192.168.8.10:29418/test
Cloning into 'test'...
ssh_dispatch_run_fatal: Connection to 192.168.8.10 port 29418: incorrect signature
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
解決方案:
vim /etc/ssh/ssh_config
添加一行:HostKeyAlgorithms ssh-rsa
在執行git clone ssh:即可,你要是還不確定,最好重新再生成一個ssh key放到gerrit上之后再執行git clone ssh