Server: CentOS 7
Client: Windows
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!
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
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
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
git init --bare /usr/local/repository/git/myGit.git //myGit is the name of the warehouse, the front is the warehouse path
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)
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