如何为Hudson/Jenkins设置私钥SSH密钥以访问Bitbucket? [英] How do i set a private ssh key for hudson / jenkins to access bitbucket?

查看:127
本文介绍了如何为Hudson/Jenkins设置私钥SSH密钥以访问Bitbucket?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Apache2设置Debian服务器作为运行Jenkins的Tomcat 7的前端-可以正常工作-但我希望Jenkins监视托管在bitbucket上的私有Mercurial存储库,我想使用SSH . (我尝试使用简单的https,但仍然不满意-SO上有一个问题答案,建议使用ssh)

I'm trying to set up a Debian server with Apache2 as a front end to Tomcat 7 running Jenkins - which is working - but i want Jenkins to monitor a private Mercurial repository hosted at bitbucket and I'd like to use SSH. (I've tried with plain https but still no joy - there is a question answer here on SO that recommends using ssh)

我已经通过将Jenkins .WAR文件拖放到/webapps中来使用Tomcat的热部署功能来部署Jenkins.我可以在服务器上生成一个公钥/私钥对,并将我的公钥添加到Bitbucket帐户中-但是,当我访问Bitbucket上的私有存储库时,如何让Jenkins使用我的私钥进行身份验证?

I've deployed Jenkins using the hot deploy capability of Tomcat by dropping the Jenkins .WAR file into /webapps. I can generate a public/private key pair on the server and have added my public key to the bitbucket account - but how do I make Jenkins use my private key to authenticate when accessing a private repository on bitbucket?

我看过一篇博客文章,其中使用apt-get在Debian上安装Hudson会创建一个Hudson用户(以便我可以为此用户添加私钥),但是通过tomcat autodeploy安装它并不会添加Jenkins用户.如果没有为Jenkins设置unix用户,我可以配置Jenkins在身份验证时使用的用户吗?

I've seen a blog post that uses apt-get to install Hudson on Debian which creates a Hudson user (so i could add a private key for this user) but installing it via the tomcat autodeploy doesn't add a Jenkins user. If there is no unix user set up for Jenkins, can I configure one that Jenkins would use when authenticating?

推荐答案

如果您可以在Jenkins中控制mercurial命令行,则可以传递--ssh命令来告诉mercurial调用什么ssh命令.这样的事情可能会起作用:

If you can control the mercurial command line from within Jenkins you can pass the --ssh command to tell mercurial what ssh command to invoke. Something like this would probably work:

hg --ssh '/usr/bin/ssh -i /path/to/private/key' ...

或者,您可以弄清Jenkins的运行用户身份(必须是 some 位用户),并将文件放入该用户的~/.ssh中,即使该用户是/root/.ssh/

Alternately you can figure out what user Jenkins is running as (it's got to be some user) and put the file in that user's ~/.ssh even if that's /root/.ssh/

这篇关于如何为Hudson/Jenkins设置私钥SSH密钥以访问Bitbucket?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆