【发布时间】:2020-12-29 10:07:34
【问题描述】:
我目前在 Windows 10 上使用 Jenkins,并使用 git 作为版本控制系统。 虽然我提供了正确的存储库 URL 和凭据,但我无法使用 jenkins,但出现以下错误。
Failed to connect to repository : Command "git.exe ls-remote -h REPOSITORY_URL HEAD" returned status code 128:
stdout:
stderr: git@URL: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
凭据和 URL 似乎没有错,因为此构建之前使用相同的凭据成功。构建成功后唯一的变化是构建脚本中的一行。
git config --global core.sshCommand C:/Windows/System32/OpenSSH/ssh.exe
在我成功使用此脚本后,git 设置一直失败。那条线有问题吗?我该如何解决?
编辑
问题解决了!对于任何有同样问题的人,这是系统用户的问题!由于 ssh 密钥存储在每个用户空间中,所以 jenkins 无法检测到 ssh 密钥的位置。因此,在windows中进入“服务”,将jenkins服务的用户更改为具有正确ssh密钥的用户。它解决了我的问题!
【问题讨论】:
-
尝试运行
C:/Windows/System32/OpenSSH/ssh.exe -T -vv git@URL直接调用带有详细输出的ssh,然后edit 你的问题包含详细输出。了解 ssh 应该使用什么 ssh 密钥文件进行连接,或者如果您不使用密钥,您将如何进行身份验证也会很有帮助。 -
@Kenster 詹金斯似乎有一些问题。它无法在 System32 中找到 OpenSSH 文件夹,因此我无法使用它登录..
-
@MarcusKim 关于服务帐户的好消息。我已将您的结论包含在答案中。
标签: windows git jenkins ssh credentials