This is the steps I completed in order to move a RHEL 7 server hosting Jenkins from using Gitlab to instead use Github.
First, ensure repos in both Gitlab and Github mirror each other (part of migration prior to this post)
Login as root and
suto the jenkins user:
su -s /bin/bash jenkins
Create ssh key pair:
1 2 3
ssh-keygen -t rsa -b 4096 -C "svc_windowsJenkins@domain.com" /var/lib/jenkins/.ssh/id_rsa_github cat /var/lib/jenkins/.ssh/id_rsa_github.pub
Copy this to Github under the service account ‘SSH Keys’. Should be like
ssh-rsa AAAAB3N...50SQ== svc_windowsJenkins@domain.com. Like before, make sure to authorize it for SSO.
Do a test clone and ensure that Github is stored in
1 2 3 4 5 6 7 8 9
eval "$(ssh-agent -s)" ssh-add /var/lib/jenkins/.ssh/id_rsa_github cd /var/lib/jenkins mkdir test cd test git init . git config --local user.name 'Service Windows Jenkins' git config --local user.email 'svc_windowsJenkins@domain.com' git clone email@example.com:company/jenkinsRepo.git
Then in each job, I went to Credentials and Added SSH username
pasted contents of /var/lib/jenkins/.ssh/id_rsa_github