How to perform GIT settings based on HTTP protocol security authentication in Linux command environment

  
                

Some users prefer to use the command line, but on the Linux system of the command line, users can only use the HTTP protocol for secure access. So in this case, how do we set up the GIT development environment? Let's take a look at the method together.

Solution:

1. Create a user name /password file (plain text password)

In his own $ HOME directory, edit .netrc file contents As follows:

machine git.xxxxx.net

login [email protected] password xxxxxx

2. Create a GnuPG key

in your own $ In the HOME directory, execute the command:

gpg --gen-key

Note: The default carriage return is OK, the RSA key is 1024, 2048 is too slow, but the security is good

You can view the generated keys using the following command:

gpg --list-key

3. Encrypt the username/password file

in your own $ In the HOME directory, execute the command:

gpg -o ~/.netrc.gpg -er yourname ~/.netrc

Note: After the execution is complete, you can delete the plaintext password file .netrc

4. Set the user's Git configuration

In your own $HOME directory, execute the command:

#This method will cache the username/password, you don't need to enter it every time.

git Config --global credential.helper 'store'

#This method requires entering a username/password each time

#git config --global credential.helper 'netrc -f ~/. Netrc.gpg -d'

At this point you can edit the .gitconfig file and fill in more information:

[user]

name = XXX

email = [email protected]

[core]

excludesfile = /home/xxx/.gitignoreglobal

[credential]

helper = store

#helper = netrc -f ~/.netrc.gpg -d

5. Start the GIT environment

1

git clone http://git. Xxxxx.net:port/project/my_project.git

Note: You need to use the new version of Git (I am using 2.2.2) and copy the git-credential-netrc script to the Git installation directory (libexec/Git-core)

The above is the way to set up the GIT development environment in the Linux system of the command line. If you need or are interested, you can try it on your own computer.

Copyright © Windows knowledge All Rights Reserved