我有一个运行在Tomcat Windows服务上的git插件的Hudson(持续集成系统)。 安装了msysgit,并且msysgit bin目录位于path中。 PuTTY / Pageant / plink已安装,并且msysgit已configuration为使用它们。
我想运行的麻烦是,拥有Tomcat / Hudson服务(本地系统)的用户没有设置SSH密钥来克隆git存储库。 当git Hudson插件尝试克隆它时会出现以下错误:
$ git clone -o origin git@hostname:project.git "e:\HUDSON_HOME\jobs\Project Trunk\workspace" ERROR: Error cloning remote repo 'origin' : Could not clone git@hostname:project.git ERROR: Cause: Error performing git clone -o origin git@hostname:project.git e:\HUDSON_HOME\jobs\Project Trunk\workspace Trying next repository ERROR: Could not clone from a repository FATAL: Could not clone hudson.plugins.git.GitException: Could not clone
我的问题是,我怎么能设置的东西,以便git插件/ msysgit知道在尝试克隆时使用特定的SSH私钥? 我不认为冠军将工作,因为Tomcat服务作为“本地系统”用户运行,但我可能是错的。
编辑:
我已经尝试将Pageant设置为服务(使用runassvc.exe),传递适当的密钥,并使其作为“本地系统”运行。 其他服务似乎无法看到选美服务的密钥。
你一定能够在非系统用户下运行。 select/创build一个用户运行Hudson,然后尝试使用ssh user @ host连接到服务器。 如果它要求密码显然没有find你的关键。
在这种情况下,仔细检查key是否加载到pageant中(每次启动时都需要从page下载相关密钥),并设置了GIT_SSH环境variables。
你可以做的另外一个方法是设置你的GIT_SSH环境variables来包含对键的引用。 我现在用tunnelier和SV做这个,所以例如我的SVN_SSHvariables是“sexec -pk = 1”,其中sexec是隧道的ssh CLI,-pk = 1告诉它使用我在槽1中的私钥。
您可以使用openssh键而不是使用putty来完成此操作; putty有需要运行的选美的挑战,但是用openssh键只需要id_rsa键在〜/ .ssh
我通常会这样做的方式是设置Jenkins作为我创build的新用户运行。 我去用户的主目录(C:\用户\默认情况下在Windows Vista和更高版本),并创build一个.ssh目录,我把我想用openssh格式的私钥id_rsa文件。
我只需要在Mac上找出类似的技巧: http : //colonelpanic.net/2011/06/jenkins-on-mac-os-x-git-w-ssh-public-key/