SSH connection between Jenkins and Gitlab

This blog will help you to setup a SSH connection between Jenkins and Gitlab.

Prerequisite

  1. Jenkins Server
  2. Gitlab Server

Run on Jenkin Server

sudo -su jenkins
ssh-keygen
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa

Configure Gitlab

cat /home/ec2-user/.ssh/id_rsa.pub

Go to Gitlab setting -> SSH Keys -> paste the key

Configure Jenkins

cat /home/ec2-user/.ssh/id_rsa

Jenkins ->Credentials -> Add Crdentials -> SSH username with private key

source:https://devops4solutions.com/ssh-jenkins-server-gitlab/