git 詹金斯:标准错误:权限被拒绝(公钥)。致命:远端意外挂断
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37432519/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jenkins : stderr: Permission denied (publickey). fatal: The remote end hung up unexpectedly
提问by Shwet
I am hosting Jenkins on a virtual machine(redhat). I am able to setup jenkins system on it and able to access jenkins. But on manage jenkinspage while creating any build job, when I giv my git repository link, I am getting this error -
我在虚拟机(redhat)上托管 Jenkins。我能够在其上设置 jenkins 系统并能够访问 jenkins。但是在创建任何构建作业时管理 jenkins页面上,当我提供我的 git 存储库链接时,我收到此错误 -
Failed to connect to repository : Command "git ls-remote -h ssh://git.aaa.aaaa.corp:XXXXX/BSA/myProject.git HEAD" returned status code 128:
stdout:
stderr: Permission denied (publickey).
fatal: The remote end hung up unexpectedly
I tried to follow many solutions related to SSH keys but of no help.
我尝试遵循许多与 SSH 密钥相关的解决方案,但没有帮助。
PLs help.
PL 有帮助。
回答by Dvir669
- Log into your server with the user you installed Jenkins and put your ssh keys under home directory (cd ~). You should have .ssh folder with your public and private keys.
- Go to your Jenkins server : http://JenkinsMaster:Port/credentialsand press "Add credentials"
- Select SSH Username with private key
- Scope is Global
- Username as the user that generated the SSH key
- Private key from the Jenkins master ~/.ssh
- Add description such as "service for GIT"
- In your job after selecting GIT as your SCM select those credentials (the field under the repository called credentials)
- 使用您安装 Jenkins 的用户登录您的服务器,并将您的 ssh 密钥放在主目录 (cd ~) 下。您应该有包含公钥和私钥的 .ssh 文件夹。
- 转到您的 Jenkins 服务器:http://JenkinsMaster:Port/凭据并按“添加凭据”
- 选择带有私钥的 SSH 用户名
- 范围是全球性的
- 用户名作为生成 SSH 密钥的用户
- 来自 Jenkins master 的私钥 ~/.ssh
- 添加描述,例如“GIT 服务”
- 在选择 GIT 作为 SCM 后的工作中选择这些凭据(存储库下的字段称为凭据)
Good luck!
祝你好运!
回答by user8683306
When you add new credentials to use jenkins, the private key (.ssh/id_rsa ) should be generate by the user jenkins.
当您添加新凭据以使用 jenkins 时,私钥 (.ssh/id_rsa) 应由用户 jenkins 生成。
- sudo -i -u jenkins
- mkdir ~/.ssh
- cd ~/.ssh
- ssh-keygen -t rsa -C "jenkins@git"
- eval "$(ssh-agent -s)"
- ssh-add ~/.ssh/id_rsa
- cat id_rsa.pub Copy the output and add it to your Git repo. done
- 须藤 -i -u 詹金斯
- mkdir ~/.ssh
- cd ~/.ssh
- ssh-keygen -t rsa -C "jenkins@git"
- eval "$(ssh-agent -s)"
- ssh 添加 ~/.ssh/id_rsa
- cat id_rsa.pub 复制输出并将其添加到您的 Git 存储库中。完毕
回答by Shwet
I have not configured Jenkins key with my gerrit key. Working now..
我没有用我的 gerrit 密钥配置 Jenkins 密钥。现在工作..