@@ -9,6 +9,7 @@ This Bash script pulls `authorized_keys` files from remote URLs and updates SSH
99- Works with:
1010 - ✅ Public URLs (method: ` raw ` )
1111 - ✅ Private GitHub repositories via GitHub API (method: ` api ` , requires token)
12+ - ✅ GitHub user public keys (method: ` ghuser ` )
1213- Safe: Only updates keys if they’ve changed
1314- Logs activity per user
1415
@@ -21,18 +22,20 @@ Each entry uses the format:
2122
2223- ** raw:** Fetches directly from a public URL.
2324- ** api:** Fetches from a private GitHub repo using the GitHub API (requires ` GITHUB_TOKEN ` environment variable).
25+ - ** ghuser:** Fetches public keys from a GitHub user's profile (provide the GitHub username after the colon).
2426
2527** Example ` users.conf ` :**
2628``` bash
2729declare -A USER_KEYS=(
2830 [" ubuntu" ]=" raw:https://example.com/ssh-keys/ubuntu.authorized_keys"
2931 [" devuser" ]=" api:https://api.github.com/repos/yourorg/ssh-keys/contents/keys/devuser.authorized_keys?ref=main"
32+ [" alice" ]=" ghuser:alice-github-username"
3033)
3134```
3235
3336## Usage
3437
35- 1 . Edit the ` users.conf ` file to define users and their key URLs.
38+ 1 . Edit the ` users.conf ` file to define users and their key URLs or GitHub usernames .
36392 . If using the ` api ` method, export your GitHub token:
3740 ``` bash
3841 export GITHUB_TOKEN=your_token_here
@@ -42,10 +45,9 @@ declare -A USER_KEYS=(
4245 chmod +x sync-ssh-keys.sh
4346 ```
44474 . Add to root's crontab:
45-
46- ``` cron
47- */15 * * * * /usr/local/bin/sync-ssh-keys.sh >> /var/log/ssh-key-sync.log 2>&1
48- ```
48+ ``` cron
49+ */15 * * * * /usr/local/bin/sync-ssh-keys.sh >> /var/log/ssh-key-sync.log 2>&1
50+ ```
4951
5052## Implementation Notes
5153
0 commit comments