ssh_askpass:exec(/app/jenkins-slave/workspace/foo@tmp/askpass_foo.sh):没有这样的文件或目录

问题描述 投票:0回答:1

在Jenkins中,我有一个带有ID,用户名,密码和私钥的凭据。

在我的jenkinsfile中,我尝试像这样使用ssh-agent:

sshagent(['my_credential_id']) {
  // sh "git something"
}

但是它不起作用,我也不知道为什么。

您知道如何调试它吗?

[Pipeline] { ( [first step] )
[Pipeline] sshagent
[ssh-agent] Using credentials [my credential description]
[ssh-agent] Looking for ssh-agent implementation...
[ssh-agent]   Exec ssh-agent (binary ssh-agent on a remote machine)
$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-UZJIW23748/agent.23748
SSH_AGENT_PID=23750
$ ssh-add /app/jenkins-slave/workspace/[project]/[project]@tmp/private_key_[XXXXXXXXXXXXXX].key
ssh_askpass: exec(/app/jenkins-slave/workspace/[project]/[project]@tmp/askpass_[XXXXXXXXXXXXXX].sh): No such file or directory
[Pipeline] // sshagent
[Pipeline] End of Pipeline
ERROR: Failed to run ssh-add
jenkins jenkins-pipeline jenkins-plugins jenkins-groovy
1个回答
0
投票

根据我的经验,您的私钥有问题。

将私钥保存到文件中,例如privatekey.txt并像这样测试它:

$ ssh -o StrictHostKeyChecking=no -i privatekey.txt [email protected]
© www.soinside.com 2019 - 2024. All rights reserved.