...
Using Multiple Deploy Keys
One way to pull code from Git to a server is to add a public SSH key as a Deploy Key in the Repo Settings. There is a problem though that each Deploy Key can only be used on one GitHub repo which requires multiple Keys. You then have the problem of telling Git which key to use with which repo.
Generate an SSH keypair per repo as usual (albeit with a unique filename) and add it to the repo as a Deploy Key.
Create a .ssh/config file which looks similar to the following -
Code Block | ||
---|---|---|
| ||
Host github.com-data_extract
Hostname github.com
IdentityFile=/home/ukrdc/.ssh/data_extract_key
Host github.com-ukrdc_database
Hostname github.com
IdentityFile=/home/ukrdc/.ssh/ukrdc_database_key
Host github.com-ukrr_quarterly_extract
Hostname github.com
IdentityFile=/home/ukrdc/.ssh/ukrr_quarterly_extract_key |
Host github.com-data_extract
This is the important part which we’ll be using in the git clone command. I have used the same value as the repo name (as with the key filenames) but I believe it just needs to be a unique value.
Clone using a command similar to -
git clone git@github.com-data_extract:renalreg/data_extract.git
Note the modified hostname to match the reference in the config file.
Useful reference Articles/Sites
...