Setting up jenkins on centos: problems with ssh keys and git

后端 未结 8 1444
忘掉有多难
忘掉有多难 2021-02-15 16:46

Went through a lot of questions, but nothing seems to be solving my issue. Or to be more precise I am not sure if I am doing the whole thing correctly. So here it is:

Ha

相关标签:
8条回答
  • 2021-02-15 17:16

    In order to login as "jenkins" user, maybe you could try this:

    sudo -s -H -u jenkins
    

    And try to invoke:

    bash-4.1$ whoami
    jenkins
    

    Hope it helps.

    0 讨论(0)
  • 2021-02-15 17:21

    1) First make jenkins as real user by editing /etc/passwd file Change

    /bin/false to /bin/bash

    2) Login to jenkins user, Now Jenkins home directory will be /var/lib/jenkins

    su - jenkins
    

    3)Generate ssh keys again ( keys will be created in /var/lib/jenkins/.ssh)

    ssh-keygen -t rsa
    

    4) copy id_rsa.pub key and paste in your git's authorized_keys file

    5) Still if it won't work, probably you have to check permissions of your .ssh directory and contents

    chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
    
    0 讨论(0)
  • 2021-02-15 17:22

    I think the .ssh directory should live in /var/lib/jenkins.

    Works for me

    0 讨论(0)
  • 2021-02-15 17:22

    jenkins is a service account, it doesn't have a shell by design. It is generally accepted that service accounts shouldn't be able to log in interactively.

    I didn't answer this one initially as it's a duplicate of a question that has been moved to server fault. I should have answered rather than linked to the answer in a comment.

    if for some reason you want to login as jenkins, you can do so with: sudo su -s /bin/bash jenkins

    0 讨论(0)
  • 2021-02-15 17:31

    I was having problems changing to the jenkins user. I needed to actually create the user properly in the system so I could log in to it. I ran this command to help me create the jenkins user in the system:

    su -s /bin/bash jenkins
    
    0 讨论(0)
  • 2021-02-15 17:32

    What I did: sudo -u jenkins ssh-keygen. It works so far

    0 讨论(0)
提交回复
热议问题