|
1 | 1 | # github-generateDeployKey
|
2 | 2 |
|
| 3 | +## About |
| 4 | + |
3 | 5 | Unlike [Bitbucket.org](https://support.atlassian.com/bitbucket-cloud/docs/add-access-keys/), [Github does not allow](https://docs.github.com/en/developers/overview/managing-deploy-keys#using-multiple-repositories-on-one-server) you to use the same public key from a server with multiple repositories. This can be inconvenient when working with multiple repositories on the same server. Creating a new user is too much of a hassel and has some limitations when making access read-only (typical access for a production server). The manual process to create and use multiple keys on the same server is also error prone.
|
4 | 6 |
|
5 |
| -This script addresses the last problem by generating a ssh key for a single repository |
6 |
| -and adds a custom configuration to the users (not global) ssh config file, |
7 |
| -and outputs the public key for you to copy and paste as the repo deploy key, |
8 |
| -and outputs the url for you to clone the repo to the machine without worrying about making errors in the process. |
9 |
| -Github docs ref https://docs.github.com/en/developers/overview/managing-deploy-keys#using-multiple-repositories-on-one-server |
| 7 | +This script addresses the last problem by: |
| 8 | + |
| 9 | +- generating a ssh key for a single repository |
| 10 | +- adding a custom configuration to the users (not global) ssh config file |
| 11 | +- outputs the public key for you to copy and paste as the repo deploy key |
| 12 | +- outputs the url for you to clone the repo to the machine |
| 13 | + |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +1. Download the script to your server and save under the user that your apps interact with `git` under |
| 18 | +2. Make the script executable with this command: `chmod u+x generateDeployKey.sh` |
| 19 | +4. Generate the deploy key with this command: `./generateDeployKey.sh REPO_OWNER_NAME REPO_NAME` |
| 20 | + |
| 21 | +## Example Usage |
| 22 | + |
| 23 | +`./generateDeployKey.sh yourname hello_world` |
10 | 24 |
|
| 25 | +## Notes |
11 | 26 |
|
12 |
| -1. Download the script to your server and save under the user that your apps run under |
13 |
| -2. Make the script executable by running the following command as the user: |
14 |
| -3. `chmod u+x generateDeployKey.sh` |
15 |
| -4. Run script like `./generateDeployKey.sh REPO_OWNER_NAME REPO_NAME` |
| 27 | +- Tested on Ubuntu Linux servers. |
| 28 | +- If you make a mistake with what you pass in (wrong repo name or project name), you can remove the change from your `~/.ssh/config` file by deleting the most recent data in the file corresponding to "New Key Generated on...." and deleting the related .pub and private keys which will be named after whatever you passed in as parameters when you executed the script (Example: `id_rsa.hello_world` and `id_rsa.hello_world.pub`). |
0 commit comments