Search code examples
jenkinsjenkins-pluginsssh-keysopensshgerrit-trigger

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


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.


Solution

  • Try to generate the key with the following command:

    ssh-keygen -m PEM