Jenkins Gerrit Trigger - "/var/lib/jenkins/.ssh/id_rsa" is not a valid key file
Asked Answered
T

2

6

I've installed Jenkins in an Ubuntu server by following the documentation from Jenkins Install documentation and I am trying to set up Gerrit Trigger Plugin. While setting up Administrative Settings section the SSH Keyfile section always gives the error "/var/lib/jenkins/.ssh/id_rsa" is not a valid key file.

I've generated the ssh keys as the Jenkins user in the default location "/var/lib/jenkins/"

I've tried generating the keys with ssh-keygen, ssh-keygen -t rsa, ssh-keygen -t rsa -b 2048 and the keys are generated with and without a passphrase also as pem file but still shows as invalid key file.

The files are present in the "/var/lib/jenkins/.ssh/" location

jenkins@jenkins:~/.ssh$ ls -la
total 16
drwx------  2 jenkins jenkins 4096 Oct  9 14:18 .
drwxr-xr-x 17 jenkins jenkins 4096 Oct  9 14:18 ..
-rw-------  1 jenkins jenkins 2602 Oct  9 14:05 id_rsa
-rw-r--r--  1 jenkins jenkins  569 Oct  9 14:05 id_rsa.pub

I didn't find any log entries regarding this in jenkins log file also not in the web portal System Log section.

Trepidation answered 9/10, 2020 at 9:1 Comment(2)
have you looked in the file? is the format correct? have you tried using the keys to ssh into another pc with ssh-copy-id ?Portamento
Yes, the file content seems fine and I can ssh to gerrit server by ssh -p 29418 -i /var/lib/jenkins/.ssh/id_rsa jenkins@gerrit-domainTrepidation
S
9

Try to generate the key with the following command:

ssh-keygen -m PEM
Surplice answered 9/10, 2020 at 12:15 Comment(2)
Do you have a reference for that?Rem
Well, that actually did not work for me.Rem
B
0

Following are the steps worked for me.

  1. Currently my Jenkins home directory is pointing to /home/home_for_jenkins .And I need to use a different BOT user to fetch the Gerrit events.

  2. In order to achieve the above requirement, I have generated ssh keys for BOT user by using ssh-keygen -m PEM command and copied the generated keys to /home/home_for_jenkins folder and changed the permissions accordingly

But answered 19/1, 2023 at 7:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.