[英]Jenkins pipeline Git error: “Host Key Verification Failed” when connecting to remote repository
I am using my PC as a server to build my Jenkins script with declarative pipeline.我正在使用我的 PC 作为服务器来使用声明性管道构建我的 Jenkins 脚本。
when running a git clone on the git bash, it works well:在 git bash 上运行 git clone 时,它运行良好:
$ git clone ssh://guillaumed@myserver.com:29418/myProjects/thisProject.git ThisFirmware
Cloning into 'ThisFirmware'...
remote: Counting objects: 889, done
remote: Finding sources: 100% (203/203)
Receiving objects: 79% (121769/152721), 48.11 MiB | 10.35 MiB/s
but running it on the same machine through pipelining :但是通过流水线在同一台机器上运行它:
sh "git clone ssh://guillaumed@myserver.com:29418/myProjects/thisProject.git ThisFirmware"
gives me the following error给我以下错误
[Pipeline] sh
+ git clone ssh://guillaumed@myserver.com:29418/myProjects/thisProject.git ThisFirmware
Cloning into 'ThisFirmware'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
any hints?任何提示?
To be sure I was using the same key, thanks to Jens, the pipeline script couldn't find the key.为了确保我使用的是相同的密钥,多亏了 Jens,管道脚本找不到密钥。
Doing cat ~/.ssh/id_rsa.pub
on the pipeline, resulted in + cat /c/windows/system32/config/systemprofile/.ssh/id_rsa.pub cat: /c/windows/system32/config/systemprofile/.ssh/id_rsa.pub: No such file or directory
在管道上执行cat ~/.ssh/id_rsa.pub
,导致+ cat /c/windows/system32/config/systemprofile/.ssh/id_rsa.pub cat: /c/windows/system32/config/systemprofile/.ssh/id_rsa.pub: No such file or directory
So I copied the ssh file from my guillaumed user ssh path to the SYSTEM ssh path but I can't use it if i'm logged in with SYSTEM user instead of guillaumed user.因此,我将 ssh 文件从我的 guillaumed 用户 ssh 路径复制到 SYSTEM ssh 路径,但如果我使用 SYSTEM 用户而不是 guillaumed 用户登录,则无法使用它。
what do I have to do?我需要做什么?
Indeed, you can't checkout with ssh if you are logged as SYSTEM.实际上,如果您以 SYSTEM 身份登录,则无法使用 ssh 结帐。
To checkout as "thisUser":要以“thisUser”的身份结帐:
You'll need to configure your Jenkins.你需要配置你的詹金斯。
1/ add a user "thisUser" 1/ 添加一个用户“thisUser”
2/ add user's ssh credentials "thisUser-ssh-credentials" 2/ 添加用户的 ssh 凭证“thisUser-ssh-credentials”
3/ use ssh-agent plugin https://wiki.jenkins.io/display/JENKINS/SSH+Agent+Plugin 3/ 使用 ssh-agent 插件https://wiki.jenkins.io/display/JENKINS/SSH+Agent+Plugin
Then configure your pipeline然后配置你的管道
dir(server_workspace)
{
sshagent(credentials: ['thisUser-ssh-credentials'] )
{
sh "git clone ssh://thisUser@domain.com:port/yourProjects/thisProject.git"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.