skip to Main Content

I installed jenkins this way : https://linuxize.com/post/how-to-install-jenkins-on-debian-9/

Basically sudo apt install jenkins while logged as root
I then created a hudson user and used ssh-keygen to generate a pair of keys.

I then tried to use the public key in the gerrit-trigger plugin (https://plugins.jenkins.io/gerrit-trigger/)

However it tells me /home/hudson/.ssh/id_rsa does not exist.
ssh key

I’m guessing it’s a permission issue. when I use apt install jenkins is there a way to specify in user hudson ?

Thnaks.

3

Answers


  1. Chosen as BEST ANSWER

    Jenkins installation created a jenkins user in debian.

    I had do su - jenkins and then create a ssh key pair for it ssh-keygen

    Then the jenkins UI is able to read this one located in /var/lib/jenkins/.ssh/id_rsa


  2. Seems you created ssh keys using root user. You need to create ssh keys while logged in as hudson user or you can change path to /root/.ssh/id_rsa

    If you want to use hudson user’s path, login to hudson user first,

    sudo su – hudson

    Then create ssh key pair:

    ssh-keygen

    Then you can confirm files using list command

    ls -a /home/hudson/

    if you see id_rsa file there, then you can put its address /home/hudson/id_rsa

    Login or Signup to reply.
  3. It seems this is permission related issue. Please change the permissions of all files in .ssh folder in /var/lib/jenkins to jenkins.

    chown jenkins:jenkins /var/lib/jenkins/.ssh && chown jenkins:jenkins /var/lib/jenkins/.ssh/*

    chmod 700 /var/lib/jenkins/.ssh && chmod 600 /var/lib/jenkins/.ssh/*

    Also make similar configuration for hudson user’s ssh key:

    su – hudson

    chmod 700 ~/.ssh && chmod 600 ~/.ssh/*

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search