How do i set a private ssh key for hudson / jenkins to access bitbucket?

我只是一个虾纸丫 提交于 2019-12-10 01:50:18

问题


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)

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?

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?


回答1:


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' ...

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/



来源:https://stackoverflow.com/questions/6323434/how-do-i-set-a-private-ssh-key-for-hudson-jenkins-to-access-bitbucket

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!