SSH Agent Plugin 1.15
SSH Credentials Plugin 1.13
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
- Add Credentials
- set Kind to "SSH Username with private key"
- tick "enter directly"
- paste a password-less private key without a trailing newline
- Attempt to use credentials (I used ssh-agent from a Jenkinsfile)
- Observe that ssh-add will prompt for a passphrase in the logs and the ssh-add has failed.
The relevant part of my logs looked like this:
[ssh-agent] Using credentials jenkins (Github SSH key)
[ssh-agent] Looking for ssh-agent implementation...
[ssh-agent] Exec ssh-agent (binary ssh-agent on a remote machine)
[ssh-agent] started an agent
$ ssh-add /var/lib/jenkins/workspace/job@tmp/private_key_2980200938951827942.key
Enter passphrase for /var/lib/jenkins/workspace/job@tmp/private_key_2980200938951827942.key: [Pipeline] // sshagent
[Pipeline] // stage
[Pipeline] // withEnv
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: Failed to run ssh-add
Adding the trailing newline to input in the web-ui resolves this issue. Adding multiple newlines didn't seem have any adverse effect so Jenkins should probably just add a newline when it writes the keyfile.