Unable to configure ssh keys to read a Gerrit repo from Jenkins

43 views
Skip to first unread message

PAUL MENA

unread,
Oct 15, 2020, 2:25:46 PM10/15/20
to Jenkins Users

I am in the process of trying to migrate Gerrit and Jenkins to a new datacenter. I have successfully installed the applications on their new hardware, but am having difficulty getting Jenkins to read from a Gerrit repository on the same server.

As the Jenkins user already existed on the server, I updated its ssh keys using one I generated from my account on my laptop (pablo@mena-xps), using the following command:

cat ~/.ssh/id_rsa.pub | ssh -p 29418 pmena@gerrit_host gerrit set-account --add-ssh-key - jenkins

I confirmed that I am able to use this key to interrogate gerrit from my laptop:

pablo@mena-xps=> ssh -p 29418 pmena@gerrit_host gerrit version
gerrit version 2.10

On the Jenkins server, I added the Private key under "Credentials" and then Configured the specific job to use that key to access a specific gerrit repo. That returns the following error in the GUI:

Failed to connect to repository : Command "git -c core.askpass=true ls-remote -h ssh://gerrit_host:29418/my_repo 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.

How can I go about troubleshooting this issue? Is there something I've overlooked in my approach? Thanks in advance.

PAUL MENA

unread,
Oct 16, 2020, 11:54:07 AM10/16/20
to Jenkins Users
To make a long story short, this issue is resolved. The Jenkins account on Gerrit was removed and recreated, after which I was able to successfully push the ssh key pair.
Reply all
Reply to author
Forward
0 new messages