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 Git multi-account support in Windows environment, that is, to manage multiple ssh-key on the same computer

2025-02-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

How to configure Git multi-account support in the Windows environment, that is, to manage multiple ssh-key on the same computer, many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.

All the places in this article where commands are executed are in administrator mode, that is, open the cmd,Git Bash client to run the program as an administrator.

1. Generate the private key and public key corresponding to github.com (the file address in this article is C:\ Users\ popfisher directory)

Execute the command ssh-keygen-t rsa-C email to create the sshkey corresponding to github, named id_rsa_github, password 123456

Ssh-keygen-t rsa-C 774232122@qq.com

two。 The private key and public key of git.oschina.net are produced in the same way (the email address can be the same or different, the same in this article)

Execute the command ssh-keygen-t rsa-C email to create the sshkey corresponding to github, named id_rsa_oschina, password 123456

Ssh-keygen-t rsa-C 774232122@qq.com3. Copy the above files to the .ssh directory accessed by default by git (win10 is in the user directory, article C:\ Users\ popfisher.ssh)

In addition to the secret key file, the config file is manually produced in the later steps, and the known_hosts file is automatically produced later.

[special attention should be paid here: if the path contains Chinese, the following config file path is not recognized by git, and there will be a problem]

4. Upload the public key corresponding to github and the public key corresponding to oschina to the server git.oschina.net and add SSH key as shown below:

5. Create a config text file in the .ssh directory and complete the configuration (at the core)

Each account is configured with a separate Host, and each Host needs an alias. Each Host is mainly configured with two attributes, HostName and IdentityFile.

The name of Host can be your favorite name, but this will affect git-related commands, such as:

If Host mygithub is defined in this way, the command is as follows, that is, the name immediately after git@ is changed to mygithub

Git clone git@mygithub:PopFisher/AndroidRotateAnim.git

HostName, this is the real domain name address.

IdentityFile, this is id_rsa 's address.

PreferredAuthentications configure what permissions to use to authenticate when logging in-- can be set to publickey,password publickey,keyboard-interactive, etc.

User configuration uses user name

The config file configuration is as follows: # configure github.comHost github.com HostName github.com IdentityFile C:\\ Users\\ popfisher\\ .ssh\\ id_rsa_github PreferredAuthentications publickey User username1# configure git.oschina.net Host git.oschina.net HostName git.oschina.net IdentityFile C:\\ Users\\ popfisher\\ .ssh\\ id_rsa_oschina PreferredAuthentications publickey User username26. Open the Git Bash client (run as an administrator) and execute the test command to test whether the configuration is successful (will automatically generate a known_hosts file in the .ssh directory to configure the private key)

7. After the test is successful, you can use git multiple accounts on the computer at the same time to operate at the same time, without affecting the project AndroidRotateAnim on clone github.

Open the AndroidRotateAnim project on github and copy its corresponding clone command as shown in the following figure

Project AndroidDevTools on clone oschina.net

Open the AndroidDevTools project on git.oschina.net

Execute the clone command as follows:

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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

Internet Technology

Wechat

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

12
Report