Establish connection between local Git and Gitlab private cloud platform

table of Contents

              Preface

              Precautions

              Start configuration

              to sum up

 

Preface

        Remote warehouses refer to project warehouses hosted on the Internet. There are many project hosting platforms on the Internet, such as github, gitlab, etc. In order not to disclose your own project code, you can build your own project warehouse on your own server, the most common is to build GitLab.

         The connection between local Git and remote server GitLab is mainly divided into: SSH and HTTP.

          HTTP method: This method requires that the project can only select the "Public" public state when it is created, and the http method cannot be used for connection in Private and Internal modes. If security is considered, security settings must be made.
          SSH method: This is a relatively safe method. The transmission between the local git repository and the remote gitlab repository is encrypted by SSH. The SSH method can be used in all three project modes.

This article mainly configures the SSH connection method:

Precautions

          The uploaded Github/GitLab account mailbox must be the same as the locally configured mailbox. That is to say, if the mailbox is different, each time you connect to a different Github/GitLab account, the local mailbox needs to be reconfigured, but ssh does not need to be regenerated, and it has been tested. . The GitLab connection is the same as Github, so it’s fine to have one side.

Start configuration

1) Generate ssh secret key

[root@hya ~]# ssh-keygen -t rsa -C "[email protected]"

2) Obtain the public key

[root@hya ~]# cd .ssh/
[root@hya .ssh]# ll
总用量 8
-rw-------. 1 root root 1675 9月  30 16:12 id_rsa
-rw-r--r--. 1 root root  402 9月  30 16:12 id_rsa.pub
[root@hya .ssh]# cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDE6g0vuSnbl/pYIdx/BAThVKzAsnDDJoEJHGVpmfyJWnUsckitVIW0FRCcwjcS6b1YVgfWTUYjTLOfr93isX3IGyv4e/dEAvwKNJW+J14amsilkE6kLztRLOOG5IUx7cOqYQcpBTMx9x1QyQRQUC+bewnrpom64Q9+vJJiteuo+skXbapPRNk1xqP69w+h56+mlrLw7cAZHUcCdnEvypfGf9rZV4Md0VlIqUryoPE339xpnd8IEMagijY9Ba3UfOy2FjchWDEjebUFD0eXVhlCFFzHxaTPI2scuVL3iMHNZsorlauiFi2GLo9p6nC+waQ23AbDhgC8jG1hgx2jMXyj [email protected]

3) Log in to Gitlab account to add public key

The last is a series of git pull operations

to sum up

            This article only talks about the ssh connection method. The httpd method has not been touched yet. I will write it out if I use it in the future.

Guess you like

Origin blog.csdn.net/yeyslspi59/article/details/108886994