@@ -9,6 +9,7 @@ This Bash script pulls `authorized_keys` files from remote URLs and updates SSH
9
9
- Works with:
10
10
- ✅ Public URLs (method: ` raw ` )
11
11
- ✅ Private GitHub repositories via GitHub API (method: ` api ` , requires token)
12
+ - ✅ GitHub user public keys (method: ` ghuser ` )
12
13
- Safe: Only updates keys if they’ve changed
13
14
- Logs activity per user
14
15
@@ -21,18 +22,20 @@ Each entry uses the format:
21
22
22
23
- ** raw:** Fetches directly from a public URL.
23
24
- ** 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).
24
26
25
27
** Example ` users.conf ` :**
26
28
``` bash
27
29
declare -A USER_KEYS=(
28
30
[" ubuntu" ]=" raw:https://example.com/ssh-keys/ubuntu.authorized_keys"
29
31
[" devuser" ]=" api:https://api.github.com/repos/yourorg/ssh-keys/contents/keys/devuser.authorized_keys?ref=main"
32
+ [" alice" ]=" ghuser:alice-github-username"
30
33
)
31
34
```
32
35
33
36
## Usage
34
37
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 .
36
39
2 . If using the ` api ` method, export your GitHub token:
37
40
``` bash
38
41
export GITHUB_TOKEN=your_token_here
@@ -42,10 +45,9 @@ declare -A USER_KEYS=(
42
45
chmod +x sync-ssh-keys.sh
43
46
```
44
47
4 . 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
+ ```
49
51
50
52
## Implementation Notes
51
53
0 commit comments