Permission denied (public key) during fetch from GitHub with Jenkins user on Ubuntu

前端 未结 8 789
盖世英雄少女心
盖世英雄少女心 2021-02-02 07:56

Here is my setup:

  1. Jenkins is running on my linux machine as \'jenkins\' user.
  2. I have generated a ssh key-pair as described in Linux - Setup Git, for the \
8条回答
  •  一整个雨季
    2021-02-02 08:33

    To summarise what must be done on the Jenkins server:

    # 1. Create the folder containing the SSH keys if necessary
    if [ ! -e ~jenkins/.ssh ]; then mkdir ~jenkins/.ssh; fi
    cd ~jenkins/.ssh/
    
    # 2. Create the SSH pair of keys
    # The comment will help to identify the SSH key on target systems
    ssh-keygen -C "jenkins" -f ~jenkins/.ssh/id_rsa -P ""
    
    # 3. Assign the proper access rights
    chown -R jenkins ~jenkins/.ssh/
    chmod 700 ~jenkins/.ssh
    chmod 600 ~jenkins/.ssh/*
    

    Remember:

    • Please keep the default "id_rsa" name when generating the keys, as other such as "id_rsa_jenkins" won't work, even if correctly set up.
    • Do not use a passphrase for your key
    • Check that the public key (id_rsa.pub) has been uploaded on the git server (GitHub, Bitbucket, etc). Once done, test your SSH key by running: ssh -vvv git@github.com (change address according to your git server)

提交回复
热议问题