Configuration of SSH key in Git


Git clone supports two ways to download source code: HTTPS and git (SSH)

When using git mode to download, if SSH key has not been configured, the following error prompts will appear:

Here’s how to configure the SSH key of GIT so that we can download the source code in Git mode.

First, check whether the user name and mailbox are configured by using the following command (unless otherwise specified, all commands are executed under git bash tool by default) (GitHub supports us to log in with user name or email address)

git config --global --list 

The display information of the author’s machine is as follows (configured)

If not configured, execute the following command to configure:

git config --global  "Change your user name here"
git config --global  "Change your email here"

Then execute the following command to generate the secret key:

SSH keygen - t RSA - C "change your email here"

Three or four confirmations are required after the command is executed:

  • Confirm the storage path of the secret key (if you do not need to change the path, press enter directly);
  • If there is already a secret key file in the save path of the previous top, you need to confirm whether to cover it (if the previous key is no longer needed, press the button to cover it directly; if necessary, manually copy it to another directory and then overlay it);
  • Create a password (press enter if no password is required);
  • Confirm the password;

The execution process is as follows:

In the specified save path, two named IDS will be generated_ RSA and ID_ Document:

Then open your GitHub and enter the configuration page

Select SSH and GPG keys

The SSH secret key was generated before, so select new SSH key (the author has configured a key here. If the user does not configure the secret key, it should be empty here)

Then open the previously generated ID with a text tool_ File, copy the contents to the input box under the key, define a name for the key (usually used to distinguish different hosts), and then save:

Try to download it in Git mode again. You can see that it can be downloaded normally

This article on git SSH key configuration details of the article introduced here, more relevant git SSH key configuration content, please search the previous articles of developeppaer or continue to browse the related articles below, I hope you can support developeppaer more in the future!