Create a git account on the host so that everyone who needs write permission can send an SSH public key and add it to ~ Sshauthorized_keys file. In this way, everyone will access the host through the git account. This does not affect the submitted data.
Create a git account on the host so that everyone who needs write permission can send an SSH public key and add it to ~ /. Ssh/authorized_keys file. In this way, everyone will access the host through the git account. This will not affect the submitted data-the identity used to access the host will not affect the submitted object information.
Step 1: Create a user on the server (git)
# Sudo addusergit
Step 2: The client generates the public key and
Create a public key: ssh-keygen,
View the generated public key and private key pair in the user directory of the client.
# Cd ~ /. Ssh
# Ls
id_dsa id_dsa.pub
The directory where the public key is located: windows is in the "C:/User/username/. ssh" directory, linux is in "~ /. Ssh ",~ Representative user directory
Step 3: add the public keys of each user under the git User server and configure the ssh service
Append the public key files of each user to the authorized_keys file of the git User on the server.
$ cat id_rsa.john.pub >> ~/.ssh/authorized_keys
$ cat id_rsa.josie.pub >> ~/.ssh/authorized_keys
$ cat id_rsa.jessica.pub >> ~/.ssh/authorized_keys
Modify the permissions of. ssh and authorized_keys). if you forget the following, the password will be entered every time (ps, it has been stuck for a long time)
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
Step 4: Create a git library under a git User
Cd gitDIR
Mkdir project. git
Cd project. git
Git init-bare
Step 5: Use the client
Submit your own database
Mkdir project
Cd project
Git init
Vi first.txt
Git remote add origin gitserver/gitDIR/project. git
Git push origin master
Clone: git clonegit @ gitserver/gitDIR/project. git
Step 6: restrict developer login
By default, users who can connect to the git server can also log on to the server through ssh directly, so the server may have the risk of being logged on by multiple users. the restricted method is as follows:
Vi/etc/passwd
Git: x: 1000: 1000:/home/git:/bin/sh |
The row is modified as follows:
Git: x: 1000: 1000:/home/git:/bin/git-shell