Heidi
Heidi

Reputation: 31

Adding ssh keyfile in jenkins gerrit trigger: "/...../.ssh/id_rsa" does not exist

I installed git, gerrit and jenkins on linux, and I installed gerrit trgger plugin on jenkins. Now I am setting the geerrit server, and trying to add the ssh key file, but it is giving me error "/home/heidi/.ssh/id_rsa" does not exist, and Bad SSH keyfile or password.

just like the image on its offical website: https://wiki.jenkins-ci.org/display/JENKINS/Gerrit+Trigger (the one in "Administrative Settings")

BUT, this location and file both are existing! Why can't these keys be found? I had trid the chmod command on .shh file and on those two keys. but it doesn't works.

Upvotes: 0

Views: 6568

Answers (3)

Brad P.
Brad P.

Reputation: 308

This is usually a symptom of either

  1. The key actually not existing (to which the answer from @nafas applies) or
  2. The key is not readable by the jenkins user (which your self-answer alludes to)

If you are logged into your jenkins server, and you navigate to /var/lib/jenkins/.ssh and do an ls -lA what you would likely see is that "root" or some other user owns the id_rsa private key you are attempting to use.

[RHEL7.2 /var/lib/jenkins/.ssh]# ls -lA
-rw------- 1 root    root    1675 Jul 11 07:45 id_rsa
-rw-r--r-- 1 root    root     398 Jul 11 07:45 id_rsa.pub
-rw-r--r-- 1 jenkins jenkins  855 Jun 26 19:57 known_hosts

Logged in as root, or using sudo, you will want to change ownership of the user and group to reflect the jenkins user and group like so: chown <user>:<group> file(s)

[RHEL7.2 /var/lib/jenkins/.ssh]# chown jenkins:jenkins id_rsa*
[RHEL7.2 /var/lib/jenkins/.ssh]# ls -lA
-rw------- 1 jenkins jenkins 1675 Jul 11 07:45 id_rsa
-rw-r--r-- 1 jenkins jenkins  398 Jul 11 07:45 id_rsa.pub
-rw-r--r-- 1 jenkins jenkins  855 Jun 26 19:57 known_hosts

Upvotes: 1

Heidi
Heidi

Reputation: 31

I finally fixed it...
post my solution here for someone who might encounter this problem int the future.
Note that the user of file jenkins which you installed.(in my case, /var/lib/jenkins and the user is "jenkins")
use "sudo su" then "su jenkins"
then generate a pair of ssh key in /var/lib/jenkins
it will no longer appear ".....dose not exist"
:)

Upvotes: 0

nafas
nafas

Reputation: 5423

you can just create a key.

Log in to your local computer as the user running servers. In a command prompt, run:

ssh-keygen -t rsa -C "[email protected]"

Just press to accept the default location and file name. If the .ssh directory doesn't exist, the system creates one for you. Enter, and re-enter, a passphrase when prompted. The whole interaction will look similar to this:

SOURCE:

https://confluence.atlassian.com/bitbucketserver/creating-ssh-keys-776639788.html

Upvotes: 0

Related Questions