1
votes

I have a private repository (organization repo) in github.

I generated rsa keys, added the public one to the github repo (with read access only).

I created credentials on Jenkins. I added the private key to it:

enter image description here

When configuring the job, it gives me the following error:

Failed to connect to repository : Command "git ls-remote -h [email protected]:XXX-Team/XXx-datalake-dataflow.git HEAD" returned status code 128: stdout: stderr: Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists

enter image description here

Could someone explain what I did wrong and how to fix it ?

2
Have you verified you can ssh to github with the private key? You should see a message saying you've successfully authenticated.Stephen Newell
@StephenNewell Yes, I can clone with this SSH key.Itération 122442
I checked my jobs, and I'm using the ID field for credentials, and it looks like you're using the username. For what it's worth I'm using pipelines, but I assume it'd be the same for other job types.Stephen Newell
Can you elaborate on that ? I'm using freestyle project and in the credentials list, there is only "none" and the one I selected. @StephenNewellItération 122442

2 Answers

2
votes

I forgot to put the passphrase of the private key when creating the credentials on Jenkins...

Thanks @VonC for his answer that made me think about it. enter image description here

0
votes

Double check (again) that ssh -Tv -i /path/to/private_key [email protected] does work.

Then double-check you have copied the full private key, from -----BEGIN RSA PRIVATE KEY----- up until -----END RSA PRIVATE KEY-----