[git] Git configuration SSH public key in new computer (Windows)

[git] Configure SSH public key for Git on a new computer (Windows).
I changed to a new computer on Friday, and I had to reinstall it in any environment. When I wanted to use Git, I forgot how to do it. This time I wrote an article and saved it. In order to save time, I ran to the Internet to search here and there...

The way of using ssh here requires the client to generate a key pair, that is, a public key and a private key. Then you need to put the public key on the github server.

The following commands are all entered in Git Bash Here, so if you have not installed Git, you can continue to look down. After installation, right-click on the computer desktop, then click Git Bash Here, a black window appears, and enter the following commands in it.

insert image description here
① Configure username:
git config --global user.name username

git config --global user.name 用户名


② Configure mailbox:
git config --global user.email mailbox

git config --global user.email 邮箱


③ Generate public key and private key:

ssh-keygen -t rsa -C 邮箱


Just press Enter all the way here, be careful not to enter anything else!

 

      这时候会提示一个地址,这个地址就是公钥、私钥存放的地址,后面有用。最后在黑窗口会出现一个方框的东西,说明密钥创建好了。(下图从网上摘取)

 

 

Then there are two files in the .ssh folder, id_rsa is the private key, and id_rsa.pub is the public key (it doesn’t matter if the known_hosts file doesn’t exist at the beginning, it’s later combined with the idea to use Git. Later, I have time to write another idea Handling Git article).


④ Configure the public key in the remote account (such as GitHub): configure the newly generated public key (content CV), and give the public key a name
⑤Finally, check whether the public key is available:

 

ssh -T [email protected]
If the following prompt appears, it means that the configuration is successful.

 

Guess you like

Origin blog.csdn.net/iblue007/article/details/126069364