I am trying to connect Jenkins to a private BitBucket repository.
I have a set (both id_rsa and id_rsa.pub) of SSH keys generated at /var/lib/jenkins/.ssh
. I've copied the id_rsa.pub
key and pasted it in the deploy keys section of my BitBucket repository. Similarly, running the command git ls-remote -h [email protected]:user/project.git
has a valid return and has been added to known_hosts
.
What might be causing my Jenkins to not connect in the git Source Code Management section of Jenkins? The error returned is:
Failed to connect to repository : Command "git -c core.askpass=true ls-remote -h https://[email protected]/user/project.git HEAD" returned status code 128: stdout: stderr: remote: Invalid username or password. If you log in via a third party service you must ensure you have an account password set in your account profile. fatal: Authentication failed for 'https://[email protected]/user/project.git/'
I also tried ssh -Tv [email protected]
as per this doc from Atlassian regarding troubleshooting SSH issues. The return states at that:
This deploy key has read access to the following repositories:
user/project: Jenkins -- jenkins@ip-xxx-xx-xx-xxx
https://[email protected]/user/project.git
for Repository URL instead of[email protected]:user/project.git
facepalm Changing it to the latter works, without the need for filling out credentials (assuming SSH has been set up successfully). – Xenyal