8
votes

I getting error "ERROR: Failed to run ssh-add" I am trying to ssh into remote machine so

SSH credential are set pic1 Pipeline script is calling ssh-agent pic2 On executing the job I get error below pic3

I have tried this reported bug https://issues.jenkins-ci.org/browse/JENKINS-50181 but it is not working and bug has been already resolved in latest version 1.17 which i have now. Can anyone suggest how to fix this issue.

2

2 Answers

11
votes

This is just a wild guess since this could have different reasons.

But I just had this error, and my problem was that when I created the credential in Jenkins I forgot to add a linebreak at the end of the input.

...
...<all the usual content>...
...
-----END OPENSSH PRIVATE KEY-----<linebreak needed here>
1
votes

I got this error when I put the SSH public key into the Jenkins credential instead of properly putting the private key.

Note that the private key is the long one that looks like this:

-----BEGIN RSA PRIVATE KEY-----
... lots of unreadable random characters for many lines ...
-----END RSA PRIVATE KEY-----