You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under Scope: Global, Id: git-jenkins, description: git-jenkins, username: [email protected] (This if followed this video. I also tried git).
Copy and Paste my private key (~/.ssh/id_ed25519.jenkins). I tried both on my linux and windows machine. Save.
When create a freestyle project, at the SCM section, I paste in the same git URI which I tested in step 3, and select the credentials from Step 7.
Expected Results
Should be able to clone the project/repo with SSH credentials stored.
Actual Results
Failed to connect to repository : Command "git ls-remote -h -- [email protected]:<path to>/myrepo.git HEAD" returned status code 128:
stdout:
stderr: [email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Anything else?
Debugging with console script
In my script console, I run the following
import jenkins.model.*
import hudson.util.Secret
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.domains.*
def credentialsStore = Jenkins.instance.getExtensionList('com.cloudbees.plugins.credentials.SystemCredentialsProvider')[0]?.store
def providedPrivateKey = """
-----BEGIN OPENSSH PRIVATE KEY-----
MyPrivateKeyContentHere
-----END OPENSSH PRIVATE KEY-----
""".trim()
println "Scanning Global Domain in System Store..."
credentialsStore?.getCredentials(Domain.global())?.each { cred ->
println "ID: ${cred.id}"
println "Description: ${cred.description}"
if (cred instanceof com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey) {
println "Username: ${cred.username}"
println "Private Key: ${cred.privateKey}"
println "Passphrase: ${Secret.toString(cred.passphrase)}"
def storedPrivateKey = cred.privateKey?.trim()
if (storedPrivateKey == providedPrivateKey) {
println "Match found for Credential ID: ${cred.id}"
} else {
println "No match for Credential ID: ${cred.id}"
}
}
println "-------------------------"
}
and my result
Scanning Global Domain in System Store...
ID: jenkins
Description: jenkins
Username: git
Private Key: -----BEGIN OPENSSH PRIVATE KEY-----
MyPrivateKeyContentHere
-----END OPENSSH PRIVATE KEY-----
Passphrase:
Match found for Credential ID: jenkins
-------------------------
Result: [com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey@99ee54b6]
The key in my credentials store matches the one I try to compare with. So now I ascertain the key are indeed correct but somehow the keys are not used properly from the store.
Are you interested in contributing a fix?
No response
The text was updated successfully, but these errors were encountered:
Jenkins and plugins versions report
Environment
What Operating System are you using (both controller, and any agents involved in the problem)?
I used to separate machines to test
Reproduction steps
Steps to reproduce the problem
The following is what I have setup for my homelab
Setting up credential steps and Issue
I generate a pair of ssh keys using
ssh-keygen -t ed25519 -C "[email protected]"
Push the public key (~/.ssh/id_ed25519.jenkins.pub) to my gitlab settings.
Test the key.
GIT_SSH_COMMAND='ssh -i ~/.ssh/id_ed25519.jenkins' git clone [email protected]:<path_to>/myrepo.git
and it works.Go to Dashboard (http://localhost:8080), Manage Jenkins, Credentials.
Under System, Global domain, Add credentials.
Under Scope:
Global
, Id:git-jenkins
, description:git-jenkins
, username:[email protected]
(This if followed this video. I also triedgit
).Copy and Paste my private key (~/.ssh/id_ed25519.jenkins). I tried both on my linux and windows machine. Save.
When create a freestyle project, at the SCM section, I paste in the same git URI which I tested in step 3, and select the credentials from Step 7.
Expected Results
Should be able to clone the project/repo with SSH credentials stored.
Actual Results
Anything else?
Debugging with console script
In my script console, I run the following
and my result
The key in my credentials store matches the one I try to compare with. So now I ascertain the key are indeed correct but somehow the keys are not used properly from the store.
Are you interested in contributing a fix?
No response
The text was updated successfully, but these errors were encountered: