git - 通过 ssh 使用 git 设置 jenkins

标签 git ssh jenkins git-clone

我正在尝试通过 ssh 使用 Git 设置 jekins。

标准执行:

git clone ssh://[username]@[server]/srv/git/[repo]

将密码存储库克隆到我的磁盘上之后。

现在在 Jenkins

ssh://[username]@[server]/srv/git/[repo].git

Failed to connect to repository : Command "git -c core.askpass=true ls-remote -h ssh://[username]@[server]/srv/git/[repo].git HEAD" returned status code 128:
stdout:
stderr: Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

enter image description here

enter image description here

或者另一种方式是 enter image description here

最佳答案

您正在通过 SSH 进行连接,这可能意味着您已经设置了基于 key 的登录,这样您就可以在没有密码的情况下进行连接。 (将 ~/.ssh/id_rsa 移动到其他位置,我敢肯定,当您执行 git 克隆时,系统也会要求您输入密码。)

在这种情况下,错误是 Jenkins 没有类似私钥设置的结果。您必须为 jenkins 生成一对公钥/私钥,并将公钥添加到您的 git 服务器,或者将您的私钥添加到 Jenkins。

相关问答:https://stackoverflow.com/a/8911280/223981

关于git - 通过 ssh 使用 git 设置 jenkins,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29792621/

相关文章:

Jenkins 管道: how can I disable the current job from inside a pipeline?

java - 启用自定义规则后,SonarQube Scanner 在 Jenkins 上失败

git - 删除不再在远程的跟踪分支

git - 如何将 IntelliJ IDEA 项目发布为 Gist

windows - 在 Windows 上的 Git 中切换多个 ssh key

linux - 打开终端后执行命令,其中使用 ssh 登录远程机器

windows - Jenkins 不能很好地处理私有(private) GitHub 存储库 (Windows)

git - `git rev-parse branchname`返回的sha1是如何推导出来的

git - 提示符 "Do you want to add the following file to Git?"究竟做了什么?

bash - 通过包含 nohup 的 ssh 启动远程脚本