Create a GIT server account
Open "Users and Groups" in "System Settings", add new User "Git", the user mainly provides the security and configuration environment of the GIT server
Figure 1 Adding a new user
Configuring the GIT server environment1. Login The user command in terminal as follows:
ssh-l git 127.0.0.1or use
su git2. Configuring the GIT server path can now be used-shared,--bareOption to run
git init
To create a bare repository, which initializes a repository that does not contain a working directory.
bogon:octopus.git git$ git init-bare--sharedInitialized empty shared Git repository in/users/git/git.repository/octopus.git/
bogon:octopus.git git$ lsHEAD Config Hooks objects Branches description Info refs 3. Configure access permissions The current author uses the SSH protocol by default (the protocol is simple and supports both read and write), and for the client it needs a public key to access the SSH server, which requires a ". SSH" public key folder for "Git" users.
bogon://git$ CD ~/.ssh
bogon:.ssh git$ ls
Authorized_keys"Authorized_keys" The file is used to authorize the user. Later, when we configure user access, we use the file. 4. Test the GIT server to exit the user terminal and use the current "kuoxin" user to access the GIT server with the following command:
bogon:temp kuoxin$ git clone ssh://[email protected]/users/git/git.repository/octopus.git
cloning into ' octopus ' ...
The authenticity of host ' 127.0.0.1 (127.0.0.1) ' can ' t be established.
RSA key fingerprint is 9E:D6:3E:4F:E5:EC:02:73:8C:3C:58:9B:D6:9B:AB:FC.
Is you sure want to continue connecting (yes/no)? Yes
warning:permanently added ' 127.0.0.1 ' (RSA) to the list of known hosts.
Password:
Warning:you appear to has cloned an empty repository.
Checking Connectivity ... done.
Configure the customer single environment1. Create a client public key when the GIT server accesses the SSH protocol, it requires SSH security access if read and write to the GIT server, so it needs to establish the user's public key and put it into the ". SSH" Directory of the Git server (currently a different account on the Mac). So that the SSH attendant program on the server can verify the user read-write access.
bogon:.ssh kuoxin$ Ssh-keygenGenerating public/private RSA key pair. Enter file in which to save the key (/USERS/KUOXIN/.SSH/ID_RSA):
Kuoxin_rsa enter passphrase (empty for no passphrase): enter same passphrase again: &nbs P your identification have been saved in kuoxin_rsa. your public key have been saved in Kuoxin_rsa.pu b. the key fingerprint is: 36:10:55:aa:9b:5b:0a:0c:b6:71:0f:ac:a7:a2:5e:97 [ email protected] the key ' s randomart image is: +--[RSA 2048]----+   ; | ..... | | . . | | . . | | . o & nbsp;| | + +. S | |. B o.+. | | o.+e+. | |. .. O.. + | |+o. o | +---------- -------+
bogon:.ssh kuoxin$ lsGithub_rsa github_rsa.pub known_hosts
Kuoxin_rsa kuoxin_rsa.pub2. Configuring client account access requires the newly generated
kuoxin_rsa.pubFile, copy to the ". SSH" directory on the GIT server, and add the developer's SSH public key to the
authorized_keys
File. Actions are as follows: Lists the public key files generated under the ". SSH" path under the current "Kuoxin" developer account
bogon:.ssh kuoxin$ lsGithub_rsa github_rsa.pub known_hosts Kuoxin_rsa
kuoxin_rsa.pubSince I am using a different account with the same machine, I need to copy the public key to the/TMP path
bogon:.ssh kuoxin$ CP kuoxin_rsa.pub/tmp/Add the public key to the Authorized_keys file in the ". SSH" Directory of the "Git" user, and if you want multiple developers to use the repository, you only need to append them individually to the
authorized_keys
At the end of the file, only the Kuoxin user's public key is currently added.
bogon:.ssh git$ cat/tmp/kuoxin_rsa.pub >> authorized_keys
3. Join the source code project to the GIT server
Bogon:git.repo kuoxin$ CD Octopus
bogon:octopus kuoxin$ git init
bogon:octopus kuoxin$ git Add.
bogon:octopus kuoxin$ git commit-m ' initial commit '
bogon:octopus kuoxin$ git remote add Origin ssh://[email protected]/users/git/git.repository/octopus.git
Bogon:octopus kuoxin$ git push Origin master4. Test engineering We use Sourcetree to test.
Figure 2 Configuring a remote git server
Figure 3 Exporting the source program
something1. The above approach is mainly suitable for small-scale team or personal use, for large teams, or to ask the company's it to do a better job. 2. The GIT server supports a variety of protocols, such as Http/https, git, local, ssh 3. Git is mostly configuration user management is more complex, you can use Gitosis.
Build a git server on MacOS