Jenkins uses ssh to connect to gitlab and cannot connect

1. Gitlab adds the public key of the jenkins server

  1. jenkins generate secret key command
ssh-keygen -t rsa

2. Jenkins secret key address:

cd   /root/.ssh

insert image description here
3. Copy the public key to gitlab to add

cat id_rsa_pub

insert image description here

4. Add private key to jenkins

cat id_rsa

insert image description here
5. Binding (if it goes well, it will end here)
(This picture is the picture when it is successful)
insert image description here
6. The solution to the connection failure
First use git to clone the ssh address of the project that needs to be helped.
insert image description here
It is found that git can pull the gitlab project
. At this time, Find the following files in the key directory

cd /root/.ssh

insert image description here
At this time, go to jenkins to bind the project with ssh credentials and no longer report an error.
insert image description here
Try to build the project successfully:
insert image description here

Guess you like

Origin blog.csdn.net/qq_44798321/article/details/131744011