jenkins/hudson can't connect to github repo

前端 未结 6 1759
不知归路
不知归路 2020-12-30 00:47

I am on Ec2 with the base amazon ami linux- I have installed jenkins but when I go to pull the repo from github I am given the following error:

Building in w         


        
相关标签:
6条回答
  • 2020-12-30 00:56

    He following helped me:

    Login under Jenkins

    sudo su jenkins
    

    Copy your github key to Jenkins .ssh folder

    cp ~/.ssh/id_rsa_github* /var/lib/jenkins/.ssh/
    

    Raname the keys

    mv id_rsa_github id_rsa
    mv id_rsa_github.pub id_rsa.pub
    
    0 讨论(0)
  • 2020-12-30 01:00

    If you log in as jenkins you can do

    ssh -i ~/.ssh/id_rsa git@github.com

    where ~/.ssh/id_rsa is the path/to/your/ssh/key and it will prompt for the password and add to the known_hosts file

    0 讨论(0)
  • 2020-12-30 01:04

    The error seems to be: host key verification failed.

    You should log into your Jenkins host as the Jenkins user and run:

    ssh git@github.com
    

    Then answer yes to the prompt about the host key. This only needs to be done once.

    Alternatively you could add "StrictHostKeyChecking no" to ~jenkins/.ssh/config.

    0 讨论(0)
  • 2020-12-30 01:12

    You need to add the ssh key of jenkins to you github user.

    Generate ssh key

    Go to:

    Github->Settings(Top right)->SSH Keys(Left Pane)->Add SSH Key

    0 讨论(0)
  • 2020-12-30 01:18

    1) Switch User into your jenkins account

    su jenkins
    

    2) Create the key without a passphrase

    3) ssh git@github.com

    That worked perfectly for me.

    You may need to create a password for the jenkins account, if so use sudo passwd jenkins

    0 讨论(0)
  • 2020-12-30 01:20

    I'm using a single jenkins machine to check out multiple github repositories and had similar problems when setting it up. What I ended up doing was configuring an SSH config file for jenkins so that SSH would automatically know which id file to associate with each repository.

    /var/lib/jenkins/.ssh/config:

    Host github-ABC
      HostName github.com
      User git
      IdentityFile /var/lib/jenkins/.ssh/id_rsa_ABC
    

    In the Jenkins project config under source code management, I used this as the repository name:

    git@github-ABC:user/repo.git
    

    Finally, I use the SSH public key as a deploy key in the github repository.

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