CentOS build private git

Server: CentOS 7

Client: Windows


One, configure the server#

1、 Install git on CentOS

yum install git
or
yum -y install git 

The effect of these two sentences is the same. If you use yum install xxxx, after you find the installation package, you will be asked Is this OK[y/d/N], You need to select manually.
But if you add parameters-y, y will be selected automatically, and you don’t need to select it manually!

2、 Create a new user##

useradd **
passwd **

3、 Add users to user groups for easy management in the future

groupadd gitGroup //Create a gitGroup user group
usermod -G gitGroup zhangsan   //Add user zhangsan to the gitGroup group

3、 Set the permissions of this user (to prevent git users from logging in to the server, just for safety, you can skip this step if you learn)

Open the /etc/passwd file

Change the newly added user (newly added, in the last line) to the following, ** is your user name

**: x:1000:1000::/home/**:/usr/bin/git-shell

6、 RSA authentication (it is one, to be precise, it is the most stringent public key authentication algorithm recognized at the moment)

Open the sshd_config file under /etc/ssh###

There are basically # comments in this file, you can find the following three, remove the front #, or directly add directly under Host

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile .ssh/authorized_keys

Then use this command to restart the sshd service

service sshd restart

7、 Add user's SSH public key

Create a public key directory

mkdir -p /home/git/.ssh/

Create key storage file

vim authorized_keys

Find id_rsa.pub (this one in the figure below) from the C:/users/username/.ssh directory of the client computer, and copy all lines to the file;

( PS: If there is no id_rsa.pub file locally on the client, execute the following commands in turn, and there will be

git config --global user.name "*Your username"
git config --global user.email "*your mailbox"
ssh-keygen   //After this input, press Enter 3 times

8、 Everything is ready, build a warehouse on the server

git init --bare /usr/local/repository/git/myGit.git   //myGit is the name of the warehouse, the front is the warehouse path

5、 Grant a power

chmod -R 777/usr/local/repository/git

(If you want to have a deeper understanding of Linux authorization, please refer to my "Linux authorization"https://cloud.tencent.com/developer/article/1551204)

Two, windows client#

1、 Download the library you built

git clone zhangsan@Server IP:/usr/local/repository/git/myGit.git //Download the remote warehouse

This will download it. The following is a series of git operations. For operations that are not familiar with git, please refer to my blog (I haven't written it yet)

supplement:

1、 If you are always prompted to enter a password, enter the following command, then pull, enter it once, and do not enter it in the future

git config --global credential.helper store

Recommended Posts

CentOS build private git
Build Yum private warehouse in Centos7.3
CentOS7 build jenkins
Centos build lnmp
Centos7 build python3.8.5+scrapy+gerapy
CentOS7.3 64 bit, build Zabbix3.4
Linux (centos7) build gitlab
Build k8s1.9.9 on centos7
CentOS6.7 build LNMP environment
Centos6.9 build rabbitmq 3.6.8 cluster
Centos7.6 build LNMP environment
Centos7 build Kubernetes cluster
Jenkins build on centos
Build Hadoop in CentOS
Centos7 build DNS service
CentOS 7 build LNMP environment
Build docker environment under Centos6.5
CentOs7.3 build Solr stand-alone service
Build OpenV** Server under CentOS7
CentOs7.3 build RabbitMQ 3.6 stand-alone service
Build zabbix monitoring zabbix4.2 in CentOS7.6
Build OpenLDAP server under CentOS7
Build zabbix monitoring zabbix4.2 in CentOS7.6
Build MariaDB replication on CentOS
Centos compile and install Git
CentOs7.3 build ZooKeeper-3.4.9 stand-alone service
CentOs7.3 build SolrCloud cluster service
CentOS 8 install Git and basic configuration
CentOS 8 (2)
CentOS8.1 build Gitlab server detailed tutorial
How to install Git on CentOS 8
CentOS configuration git server in VirtualBox
Build a PXC cluster under CentOS8
Centos7 upgrade git version control tool
Centos6 method steps to build gitlab
Build an FTP server under centos7
CentOS 8 (1)
Build Elasticsearch 6.2.4 (centos) based on docker
Build Nginx environment on Linux (CentOS)
(centos7) linux build nginx load balancing build
Centos7 build java web server tomcat
Build Discuz Forum based on CentOS
CentOS 7 install gogs git code server
virtualBox install centos, and build tomcat
Build WeChat applet service based on CentOS
Centos7 uses vim to build powerful pyt
Build WeChat applet service based on CentOS
CentOS7 build FastDFS distributed file system (on)
(1) Centos7 installation to build a cluster environment
[PHP] Build a PHP operating environment under CentOS
CentOS7 build gerrit code review service method
CentOS7 build FastDFS distributed file system (below)