jenkinsci / jenkinsci/ssh-agent-plugin
[JENKINS-38470] User-specific keys can't be found by the sshagent step
- Dominant language
- Java
- Stars
- 63
- Forks
- 81
- Avg merge
- 5h 36m
- Merged PRs (30d)
- 9
Description
I'm attempting to create a pipeline scm job that allows the user to specify their private SSH key (stored under their user-specific credentials, not the 'public' store) as a Credentials parameter and then supply that ID to the sshagent step so the git step can pull code and (later) push code to the repository as part of a gitflow workflow.
Unfortunately, while the Credentials Parameter lets me choose my key, the step can't seem to find it, even though I've made sure the Credentials Parameter supplies a valid ID. If I switch the Credentials Parameter to use a key that is available to anyone on the server, the key is found and the steps proceed correctly.
I don't want users putting private keys in a location where just anyone can use them but it seems like the credentials are not retrievable from their private store. Quick snippet:
properties([parameters([
[$class: 'CredentialsParameterDefinition',
credentialType: 'com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey',
defaultValue: '',
description: 'The SSH user and private SSH key to use for performing the release.',
name: 'SSH_USER',
required: true],
string(defaultValue: '', description: 'The version number for the release.', name: 'RELEASE_VERSION'),
string(defaultValue: '', description: 'The next development version', name: 'DEV_VERSION')])
]
)node {
stage('Checkout Software') {
// Checkout core
sshagent(["${SSH_USER}"]) {
git([branch: 'develop', changelog: false, poll: false, url: 'git@mygitserver:some-repo.git'])
}
}
---
Originally reported by gtjwilkicki, imported from: User-specific keys can't be found by the sshagent step
Raw content of original issue
I'm attempting to create a pipeline scm job that allows the user to specify their private SSH key (stored under their user-specific credentials, not the 'public' store) as a Credentials parameter and then supply that ID to the sshagent step so the git step can pull code and (later) push code to the repository as part of a gitflow workflow.
Unfortunately, while the Credentials Parameter lets me choose my key, the step can't seem to find it, even though I've made sure the Credentials Parameter supplies a valid ID. If I switch the Credentials Parameter to use a key that is available to anyone on the server, the key is found and the steps proceed correctly.
I don't want users putting private keys in a location where just anyone can use them but it seems like the credentials are not retrievable from their private store. Quick snippet:
properties([parameters([
[$class: 'CredentialsParameterDefinition',
credentialType: 'com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey',
defaultValue: '',
description: 'The SSH user and private SSH key to use for performing the release.',
name: 'SSH_USER',
required: true],
string(defaultValue: '', description: 'The version number for the release.', name: 'RELEASE_VERSION'),
string(defaultValue: '', description: 'The next development version', name: 'DEV_VERSION')])
]
)node {
stage('Checkout Software') {
// Checkout core
sshagent(["${SSH_USER}"]) {
git([branch: 'develop', changelog: false, poll: false, url: 'git@mygitserver:some-repo.git'])
}
}
- environment:
Jenkins 2.23, SSH Agent Plugin 1.13, Pipeline 2.4
Contributor guide
Assessment
This issue has not been assessed yet.