Next, let's take a look at the Github multi-account multi-project management configuration tutorial. I hope this tutorial will be helpful to everyone.
Multiple repositories are created on Github and each repository uses an independent deploy key. As a result, when performing the git push operation, the system prompts that you do not have the permission. The error message is similar:
ERROR: Permission to quyun/php-backend.git denied to quyun/aliyun-api-tools
This error was mentioned in official help:
Https://help.github.com/articles/error-permission-to-user-repo-denied-to-user-other-repo
However, for many application scenarios, using a global key does not meet the requirements.
In a simple analysis, we can find that the ssh client is similar:
Git@github.com: quyun/aliyun-api-tools.git
The user and host in the git address are used to identify which local private key is used.
Obviously, if the user and host are always git and github.com, you can only use one private key.
It is also easy to specify the private key. Edit ~ /. Ssh/config. Add a configuration similar to the following:
Host php-backend.github.quyun.net
IdentityFile ~ /. Ssh/github-php-backend
User git
Host aliyun-api-tools.github.quyun.net
IdentityFile ~ /. Ssh/github-aliyun-api-tools
User git
The configuration format is very simple. I will not explain it much.
This is not enough. You will find that the host here is no longer github.com.
I used my own host for each warehouse, and the CNAME of each host domain name was resolved to github.com, so that ssh can be used to distinguish different warehouses during connection.
To test:
# Ssh-T git@php-backend.github.quyun.net
Hi quyun/php-backend! You 've successfully authenticated, but GitHub does not provide shell access.
# Ssh-T git@aliyun-api-utils.github.quyun.net
Hi quyun/aliyun-api-tools! You 've successfully authenticated, but GitHub does not provide shell access.
You can see that ssh can use different private keys based on different hosts.
Finally, change the host in your git repository address to the new host, as shown in the following figure:
Git@github.com: quyun/aliyun-api-tools.git
Changed:
Git@aliyun-api-tools.github.quyun.net: quyun/aliyun-api-tools.git
This problem also occurs in windows. You can solve it in the same way!