Big picture: Trying to connect GitHub to Jenkins. Jenkins is running on Ubuntu under user Jenkins.(I log in as Pierre, then change to user Jenkins)
I'm following This Guide to connect the two. I'm trying to generate keys from Jenkins commandline. I used
ssh-keygen -t rsa -C 'pierre@myplace.com'
to generate the key and used standard config. But Then when I try to connect to GitHub I get the following:
jenkins@Desktop:~$ eval "$(ssh-agent -s)"
Agent pid 6328
jenkins@Desktop:~$ ssh-add -l -E md5
The agent has no identities.
jenkins@Desktop:~$ ssh-add ~/.ssh/id_rsa
Identity added: /var/lib/jenkins/.ssh/id_rsa (/var/lib/jenkins/.ssh/id_rsa)
jenkins@Desktop:~$ ssh-add -l -E md5
2048 MD5:ad:1f:9d:5c:b5:cc:8e:bb:06:5b:c2:5e:68:67:77:24 /var/lib/jenkins/.ssh/id_rsa (RSA)
jenkins@Desktop:~$ ssh -T git@github.com
Permission denied (publickey).
jenkins@Desktop:~$ eval "$(ssh-agent -s)"
Agent pid 6353
jenkins@Desktop:~$ ssh-add -l -E md5
The agent has no identities.
=> even after manually adding the keys to the ssh-agent, it will not connect!
1) What's going on with the changing PID of the agent?
2) Why is it losing its identities?
3) Why isn't it connecting?
The answers to questions 1 and 2 are the same: each eval "$(ssh-agent -s)"
is starting a new ssh agent each time. The eval
executes the text outputted at that point as shell commands, causing it to define new environment variables that tell ssh-add
and ssh
how to use the new ssh agent (which also removes the information about how to use the any other ssh agents you had started previously, though they remain running).
I don't know the answer to question 3, but it seems odd that you are trying to ssh directly to git@github.com
, and I can't find where in the guide you posted that it tells you to do that. AIUI, git@github.com
is not something you are supposed to ssh to, but instead something that just appears in URLs of Gitlab projects, but I could be wrong.