Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure SSH Key for GitHub

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "how to configure SSH Key in GitHub". The editor shows you the operation process through an actual case. The method of operation is simple, fast and practical. I hope this article "how to configure SSH Key in GitHub" can help you solve the problem.

Step 1. Set the user name and email of git

If you are using it for the first time, or if you haven't configured it yet, you need to operate the command and replace the corresponding fields yourself.

Git config-global user.name "Luke.Deng" git config-global user.email "xiangshuo1992@gmail.com"

Description: git config-- list view all the configurations of the current Git environment, and you can also configure some command aliases and so on.

2. Check whether SSH Keycd ~ / .sshls or ll// exists to see if there are id_rsa and id_rsa.pub files. If so, it means that SSH Key already exists.

The figure below is as follows

If there is no SSH Key, you need to succeed.

Ssh-keygen-t rsa-C "xiangshuo1992@gmail.com"

After execution, continue to execute the following command to get the SSH Key

Cd ~ / .sshls or ll// to see if there are id_rsa and id_rsa.pub files. If so, SSH Key already exists. 3. Get the SSH Keycat id_rsa.pub// copy key ssh-rsa at the beginning

The figure below is as follows

4. Add SSH Key to GitHub

GitHub Click on the user profile picture and select setting

Create a new SSH Key

Take a name, copy the previously copied key in, and add it.

V. Verification and modification

Test whether SSH Key is configured successfully

The result of the ssh-T git@github.com// run is similar to the following Hi xiangshuo1992! You've successfully authenticated, but GitHub does not provide shell access.

It used to be a link to https, but what if you want to submit it with SSH?

Directly modify the config file in the .git folder under the project directory and change the address.

Git address acquisition can be switched as shown in the following figure.

Verification principle

The security of SSH login is guaranteed by asymmetric encryption. When a key is generated, two keys are generated at a time, one public key and one private key, which are generally named id_rsa.pub and id_rsa in git.

So how do you use a generated private key and a public key for authentication?

Generate a key pair locally, in which the public key is placed on the remote host and the private key is saved locally

When the local host needs to log in to the remote host, the local host sends a login request to the remote host. After receiving the message remotely, it randomly generates a string and encrypts it with the public key and sends it back to the local computer. Get the string locally, decrypt it with the private key stored locally, send it to the remote again, and remotely compare whether the decrypted string is equivalent to the source string, and if so, the authentication is successful.

This is the end of the introduction on "how to configure SSH Key for GitHub". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report