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
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
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
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.
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
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
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.