This article takes CentOS as an example, other Linux please refer to the corresponding method.
1. Server-side Install git
Yum Install git
2. Add a user with no shell logon rights to the server and replace username with the user you want to add
Useradd-s/sbin/nologin username
3. Initializing the Warehouse
Git init--bare sample.git
4. In the client, that is, Gitbash (Windows user) generate the key and public key, the mailbox address to your own, of course, the following two-T and-C parameters can not.
Ssh-keygen " [email protected] "
Then to the user directory (the default), locate the. pub extension file under the. ssh folder, and the editor opens the copy
5. Open git permissions on the server and set the directory where the public key is saved
Access to SSH Setup path
vi /etc/ssh/sshd_config
Delete the comment # symbol below to save and exit
rsaauthentication Yes Pubkeyauthentication Yes authorizedkeysfile . ssh/authorized_keys
From the code above you can see the path to save authorized key under/home/git/.ssh/authorized_keys
5. Add a public key file to the server-side git configuration file
Based on the key path obtained in the previous step, we entered/home/git and found that there is no. ssh folder, new folder. SSH, and go to the folder (the default LS command is not to show the Start folder), and then create a new file Authorized_keys, Save the public key obtained in step 4th to the file and exit. Then restart SSH
cd/home/git/mkdir . SSH CD. SSH VI authorized_keys# paste in fourth step copy of Gong # Save quit
Service sshd Restart #重启sshd
6. At this point, the client can submit or update the password via git clone.
git clone [email protected]:/path/to/rep.git
Git is built under Linux server