General overview: When using Git, there are two ways to https,ssh a relationship with a target repository. HTTPS authentication is generally used (this is simple and convenient), but there is a drawback, pull,push and other operations need to enter user authentication frequently. Although the user authentication account password can be saved locally (this will lead to a new problem, local storage using plaintext-sourcetree), this time can be connected by SSH, can simultaneously solve the user frequent authentication and account security issues
Implementation steps (Windows7 environment)
1 first locally installed git, specific Baidu
2 Generate Public Private key
SSH-KEYGEN-T RSA
-t specifies the key type, which is RSA by default and can be omitted.
-C Set comment text, such as mailbox.
-f Specifies the key file Store file name
The above command omits the-C,-f parameter, so you will be prompted to enter a file name to save the generated ciphertext after running the command , then prompted to enter two password (for the push operation to enter the password, if not set, push without the need to enter password verification, directly submitted)
The public key file is then generated in the user's home directory
3 Login to GitHub and add the public key (is_rsa.pub) content to SSH key
4 Add private key to the cache Ssh-agent (the second step is to set the password)
Ssh-add ~/.ssh/id_rsa
If you cannot add directly to the ssh-agent, you can do so.
ssh-agent
is a special program designed for both pleasant and secure processing of RSA and DSA keys, which is included in the OpenSSH distribution (see part 1th of this series for an introduction to RSA and DSA certifications). Unlike ssh
, a ssh-agent
long-running Daemon (daemon), the only purpose for which it is designed is to cache the decrypted private key
5 test SSH
Ssh-t git@github.com
Output the following similar tips to demonstrate authentication success
6 Checking out git repository
Check out repository There are two ways, https,ssh, pay attention to choose the way ssh, or push still need user name password Authentication
git clone xxx
First blog, have questions to welcome correct, study together
GitHub Add SSH Authentication