Recently, I rebuilt the system and used win10. Before that, the development environment and configuration on the computer were cleared. Because of working reasons, I need to use Gitee (code cloud) and Github frequently. I used to configure one, but I don't know how to configure two at the same time, so I have this article.

Since Gitee and Github are configured at the same time, the following steps are naturally performed twice. Generally speaking, the account mailbox used on Gitee and Github should be different, so special attention should be paid to the configuration.

Create ssh key

# Enter the. ssh folder in the user directory, and the path will vary slightly depending on the operating system you use.
# It doesn't matter if you don't have this folder. You can run the next command directly.
cd ~/.ssh

# Generate key and replace the email address with the email address you use for Gitee or Github
ssh-keygen -t rsa -C ""

Next you should see the following tips:

Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/your_user_name/.ssh/id_rsa): id_rsa_gitee

If this step returns by default, a file named id_rsa will be generated. You can input different names to facilitate the identification of the file. For example, the ssh key generated by Gitee can be set to id_rsa_gitee, and the ssh key set by Github can be set to id_rsa_github. I set it here to id_rsa_gitee.

Next you will see:

Enter passphrase (empty for no passphrase):

Enter directly and you will see:

Enter same passphrase again:

Just go back. Completed generation:

Your identification has been saved in id_rsa_gitee.
Your public key has been saved in
The key fingerprint is:
The key's randomart image is:
+---[RSA 2048]----+
|        .        |
|       . .       |
|  .     . o      |
| . + .   . o     |
|  o X . S o.     |
|  .+.O o.o o*    |
|  oo=o+. .+=.+   |
|   =++E. .oo+ .  |
|  ++.*=o. .o .   |

Add public key to Gitee and Github

Find the. ssh folder in the user directory and view and copy the contents of the created or

cd ~/.ssh
# View the file content

It displays a bunch of things and duplicates them:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDZbvgUEj3XAXH4HkW27ibdXgV6VHdrA9/WdSDHtiiC55mjPvxj3OtPxIbpeJmhWyHiJWR6

Open the Gitee and Github websites to find the settings, then find SSH Keys, and add the duplicated public key.

create profile

Create a config file in the. ssh folder and add the following to distinguish the two ssh key s:

# gitee
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gitee

# github
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github

Test whether the connection is normal

On the command line, enter:

ssh -T

If the following is returned, the Github connection is normal:

Hi yourname! You've successfully authenticated, but GitHub does not provide shell access.

Continue typing on the command line:

ssh -T

If the following is returned, the Gitee connection is normal.

Welcome to, yourname!