1. Install git
Yum Install Curl-devel expat-devel gettext-devel OpenSSL-devel zlib-devel Perl-devel
Yum Install git
2. Next we create a git user group and a user to run the GIT service:
Groupadd git
AddUser git -g git
3. Import our public key into the/home/git/.ssh/authorized_keys file, one line at a.
If you do not have the file to create it:
$ cd /home/git/
$ mkdir . SSH
$ chmod . SSH
< Span class= "PLN" >< Span class= "PLN" >$ touch . Ssh/authorized_keys
$ chmod . SSH/authorized_keys
3. Initialize the GIT repository
First we select a directory as the Git repository, assuming/home/gitrepo/runoob.git, enter the command in the/home/gitrepo directory
$ cd /home
$ mkdir Gitrepo
$ chown git:git gitrepo/
$ CD Gitrepo
$ git init -bare runoob. git
< Span class= "PLN" > Initialized empty git repository in /home/gitrepo /runoob.
Change the repository owner to git:
Chown -R git:git runoob. git
4. Testing
git clone [email protected]:/home/gitrepo/runoob. git
5. For security reasons
Git server opens RSA authentication
You can then add your public key to the GIT server to verify your information. On a git server, you first need to turn on RSA authentication in/etc/ssh/sshd_config, which is:
1.RSAAuthentication yes 2.PubkeyAuthentication yes 3.AuthorizedKeysFile .ssh/authorized_keys
Disable the git user's shell login
For security reasons, the GIT user created in the second step is not allowed to log in to the shell, which can be done by editing the/etc/passwd file. Find a line similar to the following:
git:x:1001:1001:,,,:/home/git:/bin/bash
After the last colon, change to:
git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell
Build a git server under Linux