How to deploy ssh key for each Github repository
井民全, Jing, mqjing@gmail.com
Back to the Git Main Page
In this document, I'll show you how to generate a dedicated key pair for each repository. The whole idea[1] is simple and just creates ssh alias.Enjoy!
By Jing.
1. Quick
Purpose
Create two aliases representing repositories repo-0 and repo-1.
Step 1: Create aliases
File: ~/.ssh/config
Step 2: Deploy both public keys to the Deploy Key tab on GitHub project setting dashboard (here, the keys are repo-0_deploy_key.pub and repo-1_deploy_key.pub using ssh-keygen command)
Done!
Now, You can clone and access your repos by following instructions.
git push is ok.
2. Detail
Step 1: Create an ssh key for lab-python
Step 2: Deploy the key to github
[github] -> [lab-python] -> [Setting]: Deploy keys
(Edit)
Copy the output from the following command to the dashboard.
Step 3: Create an ssh alias host for the repo
Create an ssh alias hostname lab-python to represent the host github.com with the key pair id_rsa_for_lab-python.
File: ~/.ssh/config
Done!
3. Test
3.1. Test Clone
Step 1: Clone the lab-python repository using
Ex:
Result
3.2. Test Write
Result