Recently, the company was preparing to enable git to manage the company's projects. Under the guidance of the CTO header, it finally completed the configuration of the git server. Before using Git, you must first define several concepts: git server, git client, and git server administrator. This document uses Ubuntu as the git server, and pcA and pcB as the server administrator and git client respectively. Usually, OpenSSHServer, git, Gitosis, and Apache2 need to be installed on the Git server (if you want to use Git
Recently, the company was preparing to enable git to manage the company's projects. Under the guidance of the CTO header, it finally completed the configuration of the git server. Before using Git, you must first define several concepts: git server, git client, and git server administrator. This document uses Ubuntu as the git server, and pcA and pcB as the server administrator and git client respectively. Usually, OpenSSH Server, git, Gitosis, and Apache2 need to be installed on the Git Server (if you want to use Gitweb ).
This article will mainly introduce some configuration methods related to the git server and the Administrator. The client and administrator's git operation methods will be detailed in another article.
(1) Git Server
1. Use the apt-get update and apt-get upgrade commands to update the current system. If the system is not updated, some dependent packages may not be installed when you install some programs later.
2. install OpenSSH Server (ubuntu) (the current user is wirror800)
First, run the ps-e | grep ssh command to check whether the ssh service is running on the local machine. If no, continue. Otherwise, skip this step.
Run the following command:
Sudo apt-get install openssh-server
3. Modify the ssh server configuration file/etc/ssh/sshd_config (the current user is wirror800)
Port 22 # change to the login Port you want, such as 2222
PermitRootLogin no # prohibit root User Login
StrictModes yes # Check whether the key user and permissions are correct.
RSAAuthentication yes # enable RSA Authentication
PubkeyAuthentication yes # enable Public Key Authentication
PasswordAuthentication no # password authentication is disabled. It is enabled by default.
ServerKeyBits 1024 # change the intensity of ServerKey to 1024 bits after modification
PermitEmptyPasswords no # change to this status after modification. Do not log on with a blank password.
After modification, restart the ssh service:
Sudo/etc/init. d/ssh restart
Note: The SSH operation on the server end is now complete. Copy the "id_rsa file" mentioned on the Internet to the Client ~ /. Ssh/directory, copy id_rsa.pub
Server Side ~ In the/. ssh/directory, renaming authorized_keys is inaccurate. Id_rsa is the rsa private key generated using ssh-keygen. id_rsa.pub
Is a public key generated at the same time. The server administrator can create and manage the key used for communication on the server. If you want to manage the current user wirror800
Personnel are also allowed. For more information about administrator operations, see the second part of this article. We do not recommend that you create an administrator account on the ubuntu server.
It is recommended that you refer to the content of OpenSSH: http://www.freebsd.org/doc/zh_CN/books/handbook/openssh.html
4. Install git (the current user is wirror800)
Sudo apt-get install git-core
During the installation of git, you may encounter some dependent package downloading failures, mainly because of the access to the ubuntu Chinese site, we can go to its English site
Download the relevant files and install them manually. Here is a link:
Http://archive.ubuntu.com/ubuntu/pool/main/
5. Install gitosis (the first thing you need to clarify is why you need to use gitosis) (the current user is wirror800)
(1) create a folder to store the downloaded gitosis file, as shown in figure
Mkdir ~ /Gitosis_setup
(2) install gitosis
Cd ~ /Gitosis_setup
Git clone git: // eagain.net/gitosis
Cd gitosis
Sudo python setup. py install
NOTE: If python setup. py install fails, the python-setuptools.py needs to be installed
Sudo apt-get install python-setuptools.py
6. Create a system user for gitosis (the current user is wirror800)
Sudo adduser -- system -- shell/bin/sh -- gecos 'git SCM user' -- group -- disabled-password -- home/git
This method is a common method on the Internet. It creates a git user with a password disabled. However, when you use the su command to switch between git users, empty passwords are always used.
Verification Failed. You can use the following method to create a git User:
Sudo useradd-m git
Sudo password git