ssh 协议执行repo sync 报错:Permission denied (publickey)

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相对应,实现正常访问。


原文地址:https://www.cnblogs.com/xiaoerlang/p/4290621.html