"Linux Deployment • Git "Install Git on Linux system and configure it to implement SSH

Source: Internet
Author: User
Tags git clone

The leader gave me a test library that did not open the FTP and let me deploy the project. It's a practiced hand opportunity to get a whole new environment.

The operating system is: CentOs release 6.5 (Final)

Because the FTP is not open, so upload download code is very troublesome, I think of the solution is git to do synchronization and version control.

1. Check if Git is installed

Yum-y Install git

Console output:-bash:yun:command not Found "no Git Installed"

2, install Git

Yum Install git

My favorite command is Yum, which is the simplest way (in fact, I have limited command).

During the installation process, you will be prompted:

You can enter Y here.

3. Verify that Git is installed successfully

Git--version

Console output:

git version 1.7.1

This indicates that the installation was successful.

Typically, if no installation path is specified, the default installation directory for git:/usr/share/git-core/

4. Configure the SSH connection mode of git

This also proves the portability of Ssh_key in different operating systems.

I use the key from other operating systems to copy the public key, so not here to repeat the way to generate Ssh_key, if you need to know Baidu itself.

CD/.sshvi Id_rsa

Go to the. SSH directory and create a new Id_rsa file that is copied from my other available operating systems.

The Linux commands involved here are:

VI: Open file editing, if the file does not exist will be automatically created;

I: Input I will enter insert mode after opening the file;

Esc+shift+zz: The simplest operation to exit vim and save.

The same way to create:

Finally, the key is added to the ssh-agent so that the key does not work

Ssh-add/.ssh/id_rsa

5. Configure the SSH nondefault port for git (this step can be omitted)

Port 7700

The port number here uses 7700, of course, you can also set other port number according to the actual situation.

6,git Clone Project

Generally I'm used to creating a git root directory under/root/projectname/code

Cd/root/projectname/codegit initgit Clone [email protected]:P Roject-b Branch

There are too many branches, and we usually just select a branch deployment.

If the port number is not configured in the config file, then the command to clone the code can be used as follows:

git clone ssh://[email protected]:p ort/project-b Branch

7. Summary of problems encountered

(1) Execute ssh-add command error:

Could not open a connection to your authentication agent.

Workaround:

Eval ' ssh-agent-s '

(2) Execute ssh-add command error:

Permissions 0644 for '/.ssh/id_rsa ' is too open. It is required this your private key files are not accessible by others. This private key would be ignored.

Workaround:

CD/.sshchmod Id_rsa

(3) Since the beginning of my private key configuration is not placed in the/.SSH directory, but placed in the/ROOT/.SSH directory, so encountered the following problem:

Permission deined,please try again. ' [email protected] ' s password:permission denied (Publickey,gssapi-keyex,gssapi-with-mic,password) fatal:the remote End Hung up unexpectedly

This I estimate is the user permission problem, lazy from the authority this aspect to begin to solve. I can solve the problem by changing it directly to/.SSH.

----------------------------------------End-------------------------------------------------

Clap for yourself ~!!! Nice and clean.

  

"Linux Deployment • Git "Install Git on Linux system and configure it to implement SSH

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.