I'm having a frustrating time getting this set up. Currently my Bitbucket account is having a problem connecting over HTTPS and so I'm trying to connect to my repo using SSH but have encountered problems.
This is my first time using Jenkins so bear with me. I installed Jenkins using homebrew which was very simple.
- I let Jenkins install the recommended plugins which included git and ssh plugins and created a password for the admin user.
- I generated a new SSH key on my machine using the method described here, added it as an Access Key to my Bitbucket repo, and confirmed that it worked by cloning from the terminal.
- I added the SSH keys to Jenkins and it picked up the public key from my
~/.ssh
folder - I created a new Freestyle project in Jenkins and added new git repository by supplying the
git@bitbucket.org:myrepo.git
URL. - I instructed it to use my SSH key from the dropdown as credentials.
My efforts were rewarded with this error:
Failed to connect to repository : Command "git ls-remote -h git@bitbucket.org:myrepo.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.
Some Possible Leads
I've heard it said that Jenkins creates a new user on your machine and that the reason the SSH key might not work is because the jenkins user does not have access to it. I have not found any evidence of it creating a user and have even heard that it does not create a user, maybe this was old behaviour.
I've tried switching to this Jenkins users as suggested here but to no avail.
Any help would be appreciated.
Edit: One additional thing I've heard (somewhere) is that it might work better if your SSH keys were created without a passphrase. Sounds like it would be less secure in that case so I'm not sure if I should try that.