1、ssh key
已經添加ssh key到gerrit服務器,並且執行ssh協議的git clone可以正常克隆代碼到本地,可見不是ssh key的問題。
2、manifest清單文件配置
最初在manifest清單文件中配置:
<remote name="origin" fetch="ssh://git@ip:29418"/>
或者:
<remote name="origin" fetch="ssh://ip:29418"/>
3、出現問題
在客戶端執行repo init -u http://ip/manifest --repo-url http://ip/repo ,運行正常。
但是執行repo sync后,報錯:
Permission denied (publickey). fatal: The remote end hung up unexpectedly
4、解決方法
修改manifest文件的fetch元素:
<remote name="origin" fetch=".."/>
".." 意思是fetch的url和repo init時manifest的url對應。
因為ssh的url需要包含用戶名,而客戶端用戶各不相同,因此這里用".."與manifest相對應,實現正常訪問。