$npx -y skills add adityahimaone/hermes-agent-rtk-caveman --skill github-ssh-token-workflowGitHub setup with SSH keys and understanding when tokens vs SSH are needed. Covers creating dedicated SSH keys, configuring SSH config, and the limitations of SSH vs gh CLI token requirements.
| 1 | # GitHub SSH + Token Workflow |
| 2 | |
| 3 | ## Key Learning |
| 4 | **SSH authentication ≠ gh CLI authentication** |
| 5 | |
| 6 | - **SSH** (git push/pull): Works with SSH keys only |
| 7 | - **gh CLI** (API operations like creating repos): Requires personal access token |
| 8 | - **git operations** (clone, push, pull, fetch): Can use SSH keys |
| 9 | |
| 10 | ## When to Use What |
| 11 | |
| 12 | ### SSH Keys (git operations) |
| 13 | ```bash |
| 14 | git clone git@github.com:user/repo.git |
| 15 | git push |
| 16 | git pull |
| 17 | ``` |
| 18 | |
| 19 | ### Personal Access Token (gh CLI API operations) |
| 20 | ```bash |
| 21 | gh repo create user/repo --public |
| 22 | gh pr create |
| 23 | gh issue list |
| 24 | ``` |
| 25 | |
| 26 | ## Setup: Dedicated SSH Key for Hermes Agent |
| 27 | |
| 28 | ### 1. Generate SSH Key |
| 29 | ```bash |
| 30 | ssh-keygen -t ed25519 -C "hermes-agent@username" -f ~/.ssh/id_ed25519_hermes -N "" |
| 31 | ``` |
| 32 | |
| 33 | ### 2. Configure SSH Config |
| 34 | ```bash |
| 35 | cat >> ~/.ssh/config << 'EOF' |
| 36 | |
| 37 | # Hermes Agent GitHub Access |
| 38 | Host github.com-hemes |
| 39 | HostName github.com |
| 40 | User git |
| 41 | IdentityFile ~/.ssh/id_ed25519_hermes |
| 42 | IdentitiesOnly yes |
| 43 | EOF |
| 44 | ``` |
| 45 | |
| 46 | ### 3. Add Public Key to GitHub |
| 47 | ```bash |
| 48 | # Show public key |
| 49 | cat ~/.ssh/id_ed25519_hermes.pub |
| 50 | |
| 51 | # Then add at: https://github.com/settings/ssh/new |
| 52 | # Title: Hermes Agent |
| 53 | # Key: paste public key |
| 54 | ``` |
| 55 | |
| 56 | ### 4. Test Connection |
| 57 | ```bash |
| 58 | ssh -T git@github.com-hemes |
| 59 | # Expected: "Hi username! You've successfully authenticated..." |
| 60 | ``` |
| 61 | |
| 62 | ### 5. Use with Git |
| 63 | ```bash |
| 64 | # Clone using custom host |
| 65 | git clone git@github.com-hemes:user/repo.git |
| 66 | |
| 67 | # Or update existing remote |
| 68 | cd repo |
| 69 | git remote set-url origin git@github.com-hemes:user/repo.git |
| 70 | ``` |
| 71 | |
| 72 | ## Workflow: Create Repo + Push (Without gh Token) |
| 73 | |
| 74 | Since `gh repo create` needs a token but SSH works for push: |
| 75 | |
| 76 | ### Step 1: Create Repo Manually |
| 77 | 1. Go to: https://github.com/new |
| 78 | 2. Fill in: |
| 79 | - Repository name: `repo-name` |
| 80 | - Description: `Description` |
| 81 | - Public/Private |
| 82 | - ❌ Don't initialize with README |
| 83 | 3. Click "Create repository" |
| 84 | |
| 85 | ### Step 2: Push with SSH |
| 86 | ```bash |
| 87 | cd /path/to/local/repo |
| 88 | git remote add origin git@github.com-hemes:user/repo-name.git |
| 89 | git branch -M main |
| 90 | git push -u origin main |
| 91 | ``` |
| 92 | |
| 93 | ## Alternative: Use gh with Token |
| 94 | |
| 95 | If you want to create repos programmatically: |
| 96 | |
| 97 | ### 1. Find Existing Token |
| 98 | Check `~/.env` for `GITHUB_TOKEN`: |
| 99 | ```bash |
| 100 | # Option 1: Source and use |
| 101 | source ~/.env |
| 102 | echo $GITHUB_TOKEN # Format: ghp_xxxx |
| 103 | |
| 104 | # Option 2: Direct grep |
| 105 | grep "GITHUB_TOKEN" ~/.env | cut -d'"' -f2 |
| 106 | ``` |
| 107 | |
| 108 | Or create new token at: https://github.com/settings/tokens/new |
| 109 | - Note: `Hermes Agent` |
| 110 | - Expiration: 90 days (or custom) |
| 111 | - Scopes: ✅ `repo` (full control) |
| 112 | |
| 113 | ### 2. Authenticate gh CLI |
| 114 | ```bash |
| 115 | # Non-interactive authentication |
| 116 | echo "$GITHUB_TOKEN" | gh auth login --with-token |
| 117 | |
| 118 | # Verify |
| 119 | gh auth status |
| 120 | # Should show: "Logged in to github.com account adityahimaone" |
| 121 | ``` |
| 122 | |
| 123 | ### 3. Create Repo Programmatically |
| 124 | ```bash |
| 125 | cd /path/to/project |
| 126 | |
| 127 | # Create and push in one command |
| 128 | gh repo create adityahimaone/repo-name \ |
| 129 | --public \ |
| 130 | --source=. \ |
| 131 | --remote=origin \ |
| 132 | --push \ |
| 133 | --description "Repository description" |
| 134 | |
| 135 | # If repo already exists, just push |
| 136 | git remote set-url origin git@github.com-hemes:adityahimaone/repo-name.git |
| 137 | git push -u origin main |
| 138 | ``` |
| 139 | |
| 140 | ### 4. Complete Workflow Example |
| 141 | ```bash |
| 142 | # 1. Generate SSH key |
| 143 | ssh-keygen -t ed25519 -C "hermes-agent@adityahimaone" -f ~/.ssh/id_ed25519_hermes -N "" |
| 144 | |
| 145 | # 2. Add to SSH config |
| 146 | cat >> ~/.ssh/config << 'EOF' |
| 147 | |
| 148 | # Hermes Agent GitHub Access |
| 149 | Host github.com-hemes |
| 150 | HostName github.com |
| 151 | User git |
| 152 | IdentityFile ~/.ssh/id_ed25519_hermes |
| 153 | IdentitiesOnly yes |
| 154 | EOF |
| 155 | |
| 156 | # 3. Add public key to GitHub (manual) |
| 157 | cat ~/.ssh/id_ed25519_hermes.pub |
| 158 | # Add at: https://github.com/settings/ssh/new |
| 159 | |
| 160 | # 4. Test SSH |
| 161 | ssh -T git@github.com-hemes |
| 162 | |
| 163 | # 5. Authenticate gh with token from ~/.env |
| 164 | source ~/.env |
| 165 | echo "$GITHUB_TOKEN" | gh auth login --with-token |
| 166 | |
| 167 | # 6. Create repository |
| 168 | cd ~/Development/my-project |
| 169 | gh repo create adityahimaone/my-project --public --source=. --remote=origin --push |
| 170 | ``` |
| 171 | |
| 172 | ## SSH Config for Multiple Keys |
| 173 | |
| 174 | If you have multiple SSH keys: |
| 175 | |
| 176 | ```bash |
| 177 | # ~/.ssh/config |
| 178 | |
| 179 | # Personal GitHub |
| 180 | Host github.com |
| 181 | HostName github.com |
| 182 | User git |
| 183 | IdentityFile ~/.ssh/id_ed25519 |
| 184 | IdentitiesOnly yes |
| 185 | |
| 186 | # Hermes Agent GitHub |
| 187 | Host github.com-hemes |
| 188 | HostName github.com |
| 189 | User git |
| 190 | IdentityFile ~/.ssh/id_ed25519_hermes |
| 191 | IdentitiesOnly yes |
| 192 | |
| 193 | # Work GitHub |
| 194 | Host github.com-work |
| 195 | HostName github.com |
| 196 | User git |
| 197 | IdentityFile ~/.ssh/id_ed25519_work |
| 198 | IdentitiesOnly yes |
| 199 | ``` |
| 200 | |
| 201 | Usage: |
| 202 | ```bash |
| 203 | git clone git@github.com:personal/repo.git # Uses id_ed25519 |
| 204 | git clone git@github.com-hemes:hermes/repo.git # Uses id_ed25519_hermes |
| 205 | git clone git@github.com-work:work/repo.git # Uses id_ed25519_work |
| 206 | ``` |
| 207 | |
| 208 | ## Troubleshooting |
| 209 | |
| 210 | ### Permission Denied (publickey) |
| 211 | ```bash |
| 212 | # Check which key is being used |
| 213 | ssh -vT git@github.com 2>&1 | grep "Offering" |
| 214 | |
| 215 | # Test specific host |
| 216 | ssh -T git@github.com-hemes |
| 217 | |
| 218 | # Add key to agent |
| 219 | eval "$(ssh-agent -s)" |
| 220 | ssh- |