Docker jenkins image SSH keys GitHub

dockerJenkins

I have downloaded the official docker jenkins image and installed Git+GitHub plugin for Jenkins.

In the credentials menu I add the public key of my regular GitHub user (did not generate new) and in the build configuration I specify the git url. Unfortunately, I get a Permission denied (public key) from GitHub.

So I tried the HTTPS url instead with my GitHub login to ensure there was nothing wrong with the connection to GitHub. That way it is working, but I cannot understand if I need to setup the SSH keys in the container or not, is that even possible since the container only contains Jenkins itself?

Best Answer

jenkins needs the private key and GitHub needs the public key. If I were you, I would have jenkins create a new key and it will show you the public key to copy. From there in GitHub you can add the key as a Deploy Key in the project's settings.

That way jenkins will have read-only access pretty much to the repo instead of your full access.