如何从git添加ssh密钥到Jenkins? [英] How to add ssh key from git to Jenkins?
问题描述
我试图在本地机器上安装新的jenkins项目,我在 Git Repositories下的
源代码管理
部分添加了bitbucket repo。 code>
但是我得到一个错误:
无法连接到存储库:命令git ls-remote -h ssh:// git @< main_link> /< name1> /< name2> .git HEAD返回状态码128:
stdout:
stderr:权限被拒绝(publickey)。
致命:无法从远程存储库读取。
请确保您拥有正确的访问权限
并存在存储库。
我可以从我的控制台运行此命令(也可以执行 git克隆
等)
我尝试通过添加凭证
私钥 - 直接输入
据我所知,我的私钥在〜/下。 ssh /
ls〜/ .ssh /
cat〜/ .ssh / id_dsa
但是当我从 更新: 解决方案如下: 不知道在哪一步jenkins生成它是关键,但在我的情况下它已经在那里。 p> I'm trying to setup new jenkins project on local machine, I have added bitbucket repo in But I get an error: Howewer I can run this command from my console (also I can do I tried to add ssh key via As I understand my private key is under but after I have entered private ssh key from Update:
Tried this answer: https://stackoverflow.com/a/15314910/1179925
Solution is following: not sure on which step jenkins generate it's key, but in my case it was already there. 这篇关于如何从git添加ssh密钥到Jenkins?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!〜/ .ssh / id_dsa输入私人ssh密钥后
试过这个答案: https://stackoverflow.com/a/15314910/1179925
sudo -i -u jenkins
jenkins @ user-VirtualBox:〜$ git clone ssh:// git @< link> /< name1> /< name2> ;. git
克隆到'< name2>'...
权限被拒绝(publickey)。
致命:无法从远程存储库读取。
请确保您拥有正确的访问权限
并存在存储库。
#切换到jenkins用户
sudo -i -u jenkins
#获取公共密钥
cat〜 /.ssh/id_rsa.pub
#在github \\\bucket web界面中为jenkins添加公钥。
Source Code Management
section under Git Repositories
Failed to connect to repository : Command "git ls-remote -h ssh://git@<main_link>/<name1>/<name2>.git HEAD" returned status code 128:
stdout:
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
git clone
etc.)Add Credentials
with option Private Key - Enter directly
~/.ssh/
ls ~/.ssh/
cat ~/.ssh/id_dsa
~/.ssh/id_dsa
nothing changed, I still get the error.sudo -i -u jenkins
jenkins@user-VirtualBox:~$ git clone ssh://git@<link>/<name1>/<name2>.git
Cloning into '<name2>'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
#Switch to jenkins user
sudo -i -u jenkins
#Get public key
cat ~/.ssh/id_rsa.pub
#Add public key for jenkins in github\bitbucket web interface.