Create an SSH key process in detail

Transfer: https://www.cnblogs.com/ayseeing/p/3572582.html

1, github project management, you can directly use https url cloned into local, of course, can be cloned into local use SSH url.

2, copy https url and then to the inside directly clone git Bash command can be cloned into a local repository, while using SSH url clone it takes to configure and add a good SSH key before cloning.

3. If you want to clone use SSH url, it must be the owner of the project. Otherwise, the user is unable to add the SSH key.

 

Generate more public, please click: http://www.cnblogs.com/ayseeing/p/4445194.html

 

https and SSH difference:

1, the former free to clone project on github, regardless of who is; while the latter is that you must be the owner or administrator of the item you want to clone, and the need to add SSH key, otherwise it can not be cloned.

2, https url in the push time is needed to verify the user name and password; and SSH in push when it is not required to enter a user name, if configured SSH key when the password is set, you need to enter a password, or else directly is not need to enter a password.

 

Add SSH key step on github:

1, you first need to check whether the computer has SSH key 

Run git Bash client, enter the following code:

$ cd ~/.ssh
$ ls

These two commands is to check whether there has been or id_dsa.pub id_rsa.pub file, if the file already exists, then you can skip step 2, go directly to Step 3.

 

2, create a SSH key 

$ ssh-keygen -t rsa -C "[email protected]"

Code Definition:

-t type Specifies the key, the default is RSA, can be omitted.
-C comment text settings, such as the mailbox.
-f filename Specifies the key file is stored.

The above code omitted -f parameter, therefore, run one above command will let you enter a file name to save the SSH key codes 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 not enter the file name, use the default filename ( recommended ), it will generate two keys id_rsa and id_rsa.pub file.

 

Then will prompt you to enter the password twice (the password is the password file when you push to enter, rather than github administrator password),

Of course, you can not enter a password, just press Enter. Then push when you do not need to enter a password, submitted directly to the github, such as:

Enter passphrase (empty for no passphrase): 
# Enter same passphrase again:

Next, the display will prompt the following code, such as:

Your identification has been saved in /c/Users/you/.ssh/id_rsa.
# Your public key has been saved in /c/Users/you/.ssh/id_rsa.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 a close above this code, it shows that your SSH key has been created successfully, you only need to add the SSH key github on it.

 

3, add your SSH key to go above github

a, first you need to copy the contents of id_rsa.pub file, you can open the file with a copy editor, you can also command to copy the contents of the file with git, such as:

$ clip < ~/.ssh/id_rsa.pub

b, log in to your github account, but also from the upper corner of the set (  the Account Settings  ) to enter, then click on the menu bar SSH key to enter the page to add SSH key.

c, click on the Add SSH key button to add a SSH key. Paste the code for your copy of SSH key to the key corresponding to the input box, remember before and after the SSH key codes do not leave a space or carriage return. Of course, the above Title corresponding input box you can enter an alias for the SSH key on a display of github. The default will use your e-mail name.

 

4, test the SSH key

Enter the following code in git Bash

When you enter the above code, there will be a warning codes, 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. # Are you sure you want to continue connecting (yes/no)?

This is normal, you can enter a carriage return yes. If you create SSH key when you set a password, then you will be prompted to enter a password, such as:

Enter passphrase for key '/c/Users/Administrator/.ssh/id_rsa':

Of course, if you enter the wrong password, and will then ask you to enter, know so far.

Note: If you enter the wrong password will not correct a word, use the delete key can not be corrected.

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 up SSH keys. If you see "access denied", said they denied access, then you need to use to access https instead of SSH.

 

Production test document: https: //help.github.com/articles/generating-ssh-keys

 

Guess you like

Origin www.cnblogs.com/yinminbo/p/11810302.html