Simple setup of git server

Source: Internet
Author: User
Tags ssh server
Git server simple setup 1. generate a public key. Any engineer who needs to use the git server must generate an ssh public key. You can use ssh-keygen to generate www.2cto.com ~ /. Ssh $ ssh-keygenGeneratingpublic/privatersakeypair. Ente... simple setup of the git server 1. public key generation any engineer who needs to use the git server must generate an ssh public key. You can use ssh-keygen to generate www.2cto.com ~ /. Ssh $ ssh-keygenGenerating public/private rsa key pair. enter file in which to save the key (/home/shiz.pdf /. ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in/home/shiz.pdf /. ssh/id_rsa.Your public key has been saved in/home/shiz.pdf /. ssh/id_rsa.pub.The key fingerprint is: a8: 19: 49: f4: e6: e8: 4f: 8f: 3e: 47: c9: 19: 4c: 09: ee: 7f shizmart @ sz-your topthe key's randomart image is: first, you will be asked to enter the location where you want to save the public key, press enter directly, and then you will be prompted to repeat the password twice,
If you do not want to use the public key again, enter the password and press enter. The. ssh directory under the home directory
Generate two files: id_rsa (private key) and id_rsa.pub (public key ). Www.2cto.com sends the generated public key id_rsa.pub to the git repository administrator. 2. set up the server (1) it is best to create a git group on the server side, and then add another git User to the group. Sudo adduser gitsu gitcd ~ Mkdir. ssh creates a. ssh Directory for the git User and adds the developer's SSH public key to the authorized_keys of the git User.
In this file. There are two developers, zhangsan and lisi. Www.2cto.com cat/tmp/id_rsa_zhangsan.pub> ~ /. Ssh/authorized_keyscat/tmp/id_rsa_lisi.pub> ~ /. Ssh/authorized_keys create an empty repository cd workmkdir project. gitcd project. gitgit -- use bare init -- bare will initialize a repository without any working directory and will not see the source code of the project. To prevent developers from entering IP addresses every time they clone code, you can use DNS. The specific operation is as follows: add the following line 192.168.1.100 gitserver (2) to sudo vim/etc/hosts. if there is no warehouse, you must first create a warehouse. To create a repository, run the following command in the directory. Cd my_projectgit initgit add. (add all files to the repository for management) git commit-m "initial commit" git remote add origin git @ gitserver:/home/git/work/project. git (I .e.: git@192.168.1.100:/home/git/work/project. git) git push origin master if there is a local repository, but you want to push the code to our new server, you can directly use the following command to create a new master branch git checkout-B master xxxxxgit push origin master, which can work on a simple server, other developers can develop code directly from the server.
Www.2cto.com to protect the git server and restrict developers from logging on to the server, the following measures can be taken. Sudo vim/etc/passwd finds the git: x: 1001: 1001:,:/home/git: class at the end of the file: /bin/bash: Change/bin/bash/to/user/bin/git-shell. now developers can only push and obtain code through SSH and cannot log on to the ssh server. 3. question? What is the same for ssh? Tom Pepper ?? When F ??? Information Agent admitted failure to sign using the key solution? Q: Use the ssh-add command to add the private key (change id_rsa according to the name of the private key), that is, the respective developers execute the command ssh-add id_rsa.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.