Using tuserver to build a Git Server

Source: Internet
Author: User
The SSH protocol is used to perform server authorization management through the public key and private key, and is the standard protocol for git read/write operations. Assume that cglab uses the server administrator account and labserver as the host name. 1. First install the public key and private key of openssh $ sudoapt-getinstallopenssh-server2.SSH on the linuxserver server, the generated public key can be used for different purposes, such as the id_rsa.pub Public Key generated below as shell

The SSH protocol is used to perform server authorization management through the public key and private key, and is the standard protocol for git read/write operations.

Assume that cglab uses the server administrator account and labserver as the host name.

1. First install openssh on the linux server

$ Sudo apt-get install openssh-server

2. SSH public key and private key. The generated public key can be used for different purposes. For example, the id_rsa.pub Public Key generated below is used for shell login, while gitadmin. pub is used for git access.

(1) create a public key and a private key

$ Ssh-keygen // The operation is performed on the client,

This command will create the. ssh directory in the user's home directory and create two files in it:

L id_rsa: private key file. Is created based on the RSA algorithm. The private key file should be properly kept and kept confidential.

L id_rsa.pub, public key file. This file is a pair of id_rsa files that can be made public as a public key file.

After creating your own public/private key pair, you can use the following command to log on to the remote server without a password, that is, replace Password Authentication with public key authentication.

$ Ssh-keygen-f ~ //. Ssh/gitadmin // This command creates a public/private key file pair named gitadmin.

(2) Upload the public key to the server

$ Scp ~ //. Ssh/gitadmin. pubcglab @ labserver:/tmp // upload the file to the server for gitolite access. For more information, see the following section.

$ Scp ~ /. Ssh/id_rsa.pubcglab @ labserver:/tmp // upload to the server for shell access

(3) Use the uploaded Public Key for different purposes as needed

$ Ssh cglab @ labserver // log on to the server with the cglab account

Cglab @ labserver :~ $ Sudo ssh-copy-id-I/tmp/id_rsa.pubgitadmin @ labserver // Add to the SSH Login identity gitamdin for shell access

(4) SSH host alias

Return to the client and go ~ Create an ssh host alias under/. SSH/to facilitate login to the server to access the shell.

$ Vi ~ /. Ssh/config

The content is:

Host admin

User gitadmin // authentication used to log on to the server

Hostname labserver // server host name

Port 22

Identityfile ~ // Ssh/id_rsa // The public/private key pair used. id_rsa is used here.

(5) log on to the server through SSH

$ Ssh gitadmin // use the alias to log on to the server as the server account gitadmin and log on to the shell.

$ Ssh gitadmin @ labserver // The default id_rsa is used for authentication. you can log on to the shell.

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.