How to Generate and Configure SSL Certificates for Multiple Accounts in a Windows Environment

Table of contents

 

Step 1: Generate your own private and public keys

Step 2: Create and edit the configuration file config

 Step 3: Open the Git Bash client (run as an administrator) and execute the test command to test whether the configuration is successful (the known_hosts file will be automatically generated in the .ssh directory and the private key will be configured in it)


Step 1: Generate your own private and public keys

cd ~/.ssh
ssh-keygen -t rsa -C "[email protected]"
Enter file in which to save the key (/c/Users/icecr/.ssh/id_rsa): XXXXXX #这里注意不同账号需要不同的命名,否则默认都是id_rsa

 At this time, the XXXXXX and XXXXXX .pub files with the names you specified will be generated in the C:/User/account/.ssh directory. The file with the suffix pub is the public key. Open it with any text editor, copy it, and paste it to a different The required public key in the git platform is generally a title and a public key text, such as github as shown below

After completion, repeat the first step until the accounts required by different git platforms are created, and the public key is uploaded and published.

Step 2: Create and edit the configuration file config

The file needs to be a directory with .ssh. The structure of each block of the file is:

#github                                    #github的git账号配置
Host github                                #叫什么随意,只是区分
HostName github.com                        #此处必须为对应git的实际域名地址
PreferredAuthentications publickey         #验证方式
User usr1                                  #git账号名
IdentityFile C:\Users\xxxx/id_rsa_github   #对应的秘钥文件名,即第一步生成的文件名,不需要写.pub后缀

#aliyun                                    #阿里云的git仓库配置                            
Host aliyun.code
HostName code.aliyun.code
PreferredAuthentications publickey
User usr2
IdentityFile C:\Users\xxxx\.ssh\id_rsa

 Step 3: Open the Git Bash client (run as an administrator) and execute the test command to test whether the configuration is successful (the known_hosts file will be automatically generated in the .ssh directory and the private key will be configured in it)

After completion, you can use different git accounts for version control operations.

 

Guess you like

Origin blog.csdn.net/blackhost/article/details/117048071