The advantage of using SSH key to verify GitHub is that you do not need to enter the user name and password each time you submit the code, because, to a certain extent, it has a great impact on efficiency, although this can prevent too many times of code submission, it is also a matter of personal habits.
Today, I tried to configure the SSH key.
OS: Mac OS
Open the console and create a directory, such ~ /. SSH)
Enter the following command in the directory:
ssh-keygen -t rsa -C "[email protected]"
Note: Replace the double quotation marks with your own email address. If you encounter permission problems, you only need to add sudo to the front.
Generating public/private RSA key pair. enter file in which to save the key (/var/root /. SSH/id_rsa ):. /id_rsa # enter the path to save the file: Enter passphrase (empty for no passphrase): # directly press enter to skip enter same passphrase again: # Same as your identification has been saved in. /id_rsa.your public key has been saved in. /id_rsa.pub.the key fingerprint is: 25: 68: 54: 4A: F1: 03: AB: 78: 15: 3f: F7: 9d: F0: BF: 08: EE [email protected] The key's randomart image is: + -- [RSA 2048] ---- + | * o. | o | ** O. |. + *. +. |. o s. + | .. | .. | .... |. E .. | + --------------- +
At this time, there are two files under the. Ssh directory
id_rsa id_rsa.pub
Id_rsa is the private key id_rsa.pub is the public key.
Then, execute the following command to add the generated key
ssh-add id_rsa
Copy the content in id_rsa.pub, find add keys in settings on GitHub, and paste it to the key. Enter the title as needed.
In this case, you can test it on the console.
$ ssh -T [email protected]The authenticity of host ‘github.com (192.30.252.128)‘ 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)? yesFailed to add the host to the list of known hosts (/Users/Bsn/.ssh/known_hosts).Hi bsnwong! You‘ve successfully authenticated, but GitHub does not provide shell access.
If you see the last line, the verification is successful.
After that, I forgot to execute the ssh-add id_rsa command at the beginning. The verification failed and it was stuck here for a long time.
Use SSH key to verify GitHub