Using SSH to build a remote git repository
1. Log on to the server using SSH to create a repos warehouse directory
2. Create a user group GIT-RW
Groupadd GIT-RW
3. Change the Repos directory group to GIT-RW group permissions
Chgrp-r GIT-RW Repos
4. Add write permission to the Repos group
chmod g+w repos, so as long as the users of the GIT-RW group have write access to the Repos directory
5. Create a user gitteacher and assign it to the GIT-RW group
Useradd-m-G GIT-RW gitteacher//-m parameter is create user, otherwise create default host directory
passwd Gitteacher
6. Create a git repository locally
mkdir Git_teacher
Git init
Touch readme.md
Git add-a
Git commit-m "init git"
7. Return to the parent directory and then clone out of a bare repository
git clone--bare git_teacher git_teacher.git
8. Then copy the cloned warehouse SCP to the remote repository
----
You can initialize an empty warehouse directly above the server
Git init--bare--shared git_server.git
The above is a git operation using an SSH user, now using git public key for git operation
1. Create a git user
Useradd git
2. Switch to a git user
Su git
3. Create the. SSH directory under the GIT host directory
mkdir. SSH
chmod. SSH
Touch Authorized_keys & chmod Authorized_keys
Ssh-keygen Generating private and public keys
Attention:
If you use a public key, you must have git repository write permissions to Git
Git Server Setup