Note: This article is from the Broken Boy blog (http://www.cnblogs.com/ayseeing/p/3572582.html) can effectively solve the problem.
Many friends use GitHub to manage projects, using the HTTPS URL to clone directly to the local, and of course some people use the SSH URL to clone to the local. However, why do most people use HTTPS URL cloning?
This is because the use of HTTPS URL cloning is more convenient for beginners, copy the HTTPS URL and then into the git Bash directly cloned to the local clone command is good. Using SSH URL cloning requires that SSH key be configured and added before cloning.
Therefore, if you want to use the SSH URL clone, you must be the owner of the project. Otherwise you will not be able to add SSH key.
To generate multiple public keys, click: http://www.cnblogs.com/ayseeing/p/4445194.html
The difference between HTTPS and SSH:
1. The former can clone the project on GitHub at will, regardless of who it is, while the latter is you must be the owner or administrator of the project you want to clone, and you need to add SSH key first, otherwise you cannot clone.
2, HTTPS URL in the push is required to verify the user name and password, and SSH in the push, is not required to enter the user name, if the configuration of SSH key set password, you need to enter the password, or directly do not need to enter a password.
To add SSH keys on GitHub: 1, first check if your computer already has SSH key
Run the Git Bash client and enter the following code:
$ cd ~/.ssh$ ls
These two commands are to check if a id_rsa.pub or id_dsa.pub file already exists, and if the file already exists, you can skip step 2 and go directly to step 3.
2. Create an SSH key
$ ssh-keygen-t rsa-c "[Email protected]"
Code parameter meaning:
-t specifies the key type, which is RSA by default and can be omitted.
-C Set comment text, such as mailbox.
-f Specifies that the key file stores the file name.
The above code omits the-f parameter, so running the above command will allow you to enter a file name to hold the SSH key code you just generated, such as:
Generating public/private RSA key pair.# Enter file in which to save the key (/C/USERS/YOU/.SSH/ID_RSA): [Press Enter]
Of course, you can also not enter the file name, using the default file name (recommended), then the Id_rsa and id_rsa.pub two key files will be generated.
Then you will be prompted to enter the password two times (the password is the password you want to enter when you push the file, not the GitHub manager's password),
Of course, you can also do not enter the password, press ENTER directly. Then push will not need to enter a password, directly submitted to GitHub, such as:
Enter passphrase (empty for No passphrase): # Enter same passphrase again:
Next, you will see the following code hints, such as:
Your identification have been saved in/c/users/you/.ssh/id_rsa.# Your public key have been saved In/c/users/you/.ssh/id_rs a.pub.# the key fingerprint is:# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db [email protected]
When you see the above code, it means that your SSH key has been created and you just need to add it to GitHub's SSH key.
3. Add your SSH key to GitHub
A, first you need to copy the contents of the Id_rsa.pub file, you can use the editor to open the file copy, you can also use the git command to copy the contents of the file, such as:
$ clip < ~/.ssh/id_rsa.pub
B, log in to your GitHub account, enter from the top corner of the Setup tab, and then click the SSH key in the menu bar to add SSH key to the Settings page.
C, Click the Add SSH Key button to add an SSH key. Paste your copy of the SSH key code into the corresponding input box key, remember SSH key code before and after do not leave a space or enter. Of course, the input box for the Title above can also be entered as an alias for the SSH key displayed on GitHub. The default is to use your message name.
4. Test the SSH key
Enter the following code in Git Bash
$ ssh-t [email protected]
When you enter the above code, there will be a warning code, such as:
The authenticity of host ' github.com (207.97.227.239) ' can ' t be established.# RSA key fingerprint is 16:27:ac:a5:76:28:2d: 36:63:1b:56:4d:eb:df:a6:48.# is sure you want to continue connecting (yes/no)?
It's normal for you to enter Yes to either. If you set a password when you create SSH key, you will be prompted to enter the password, such as:
Enter passphrase for key '/c/users/administrator/.ssh/id_rsa ':
Of course, if your password is wrong, you will be asked to input, know the right so far.
Note: If you enter a password incorrectly, you will not be able to correct it by using the DELETE key.
After the password is correct, you will see the following passage, such as:
Hi username! You ' ve successfully authenticated, but GitHub does not# provide shell access.
If the user name is correct, you have successfully set the SSH key. If you see "Access Denied", you will need to use HTTPS to access, not SSH, if you deny access.
If you have any questions or corrections, please leave a message.
Production Documents: Https://help.github.com/articles/generating-ssh-keys
GitHub Settings Add SSH (reprinted from: Broken Boy)