Details
-
Bug
-
Status: Resolved (View Workflow)
-
Minor
-
Resolution: Fixed
-
None
-
-
ssh-credentials-1.17.1
Description
Repro:
- 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:
```
[Pipeline] sshagent
[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
SSH_AUTH_SOCK=/tmp/ssh-rEGjLSRTHULl/agent.3927
SSH_AGENT_PID=3929
[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] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: Failed to run ssh-add
Finished: FAILURE
```
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.
Attachments
Issue Links
- is duplicated by
-
JENKINS-43564 Ensure newline at the end of SSH key blocks
-
- Resolved
-
- links to
Activity
Field | Original Value | New Value |
---|---|---|
Description |
Repro: - 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 ssg-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: ``` [Pipeline] sshagent [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 SSH_AUTH_SOCK=/tmp/ssh-rEGjLSRTHULl/agent.3927 SSH_AGENT_PID=3929 [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] } [Pipeline] // stage [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: Failed to run ssh-add Finished: FAILURE ``` 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. |
Repro: - 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: ``` [Pipeline] sshagent [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 SSH_AUTH_SOCK=/tmp/ssh-rEGjLSRTHULl/agent.3927 SSH_AGENT_PID=3929 [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] } [Pipeline] // stage [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: Failed to run ssh-add Finished: FAILURE ``` 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. |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Fixed but Unreleased [ 10203 ] |
Released As | ssh-credentials-1.17.1 | |
Status | Fixed but Unreleased [ 10203 ] | Resolved [ 5 ] |
Remote Link | This issue links to "jenkinsci/ssh-credentials-plugin#46 (Web Link)" [ 25009 ] |
Link |
This issue is duplicated by |
Thanks for reporting the issue!
Sounds reasonable to me, although probably a newline should only be added if there isn't one already so that resaving the credentials doesn't keep adding newlines. Feel free to submit a pull request to the repository (ideally with a regression test); here is the class that I think would need to be modified.