| name | github-ssh-token-workflow |
| description | GitHub 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. |
| category | github |
GitHub SSH + Token Workflow
Key Learning
SSH authentication ≠ gh CLI authentication
- SSH (git push/pull): Works with SSH keys only
- gh CLI (API operations like creating repos): Requires personal access token
- git operations (clone, push, pull, fetch): Can use SSH keys
When to Use What
SSH Keys (git operations)
git clone git@github.com:user/repo.git
git push
git pull
Personal Access Token (gh CLI API operations)
gh repo create user/repo --public
gh pr create
gh issue list
Setup: Dedicated SSH Key for Hermes Agent
1. Generate SSH Key
ssh-keygen -t ed25519 -C "hermes-agent@username" -f ~/.ssh/id_ed25519_hermes -N ""
2. Configure SSH Config
cat >> ~/.ssh/config << 'EOF'
Host github.com-hemes
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_hermes
IdentitiesOnly yes
EOF
3. Add Public Key to GitHub
cat ~/.ssh/id_ed25519_hermes.pub
4. Test Connection
ssh -T git@github.com-hemes
5. Use with Git
git clone git@github.com-hemes:user/repo.git
cd repo
git remote set-url origin git@github.com-hemes:user/repo.git
Workflow: Create Repo + Push (Without gh Token)
Since gh repo create needs a token but SSH works for push:
Step 1: Create Repo Manually
- Go to: https://github.com/new
- Fill in:
- Repository name:
repo-name
- Description:
Description
- Public/Private
- ❌ Don't initialize with README
- Click "Create repository"
Step 2: Push with SSH
cd /path/to/local/repo
git remote add origin git@github.com-hemes:user/repo-name.git
git branch -M main
git push -u origin main
Alternative: Use gh with Token
If you want to create repos programmatically:
1. Find Existing Token
Check ~/.env for GITHUB_TOKEN:
source ~/.env
echo $GITHUB_TOKEN
grep "GITHUB_TOKEN" ~/.env | cut -d'"' -f2
Or create new token at: https://github.com/settings/tokens/new
- Note:
Hermes Agent
- Expiration: 90 days (or custom)
- Scopes: ✅
repo (full control)
2. Authenticate gh CLI
echo "$GITHUB_TOKEN" | gh auth login --with-token
gh auth status
3. Create Repo Programmatically
cd /path/to/project
gh repo create adityahimaone/repo-name \
--public \
--source=. \
--remote=origin \
--push \
--description "Repository description"
git remote set-url origin git@github.com-hemes:adityahimaone/repo-name.git
git push -u origin main
4. Complete Workflow Example
ssh-keygen -t ed25519 -C "hermes-agent@adityahimaone" -f ~/.ssh/id_ed25519_hermes -N ""
cat >> ~/.ssh/config << 'EOF'
Host github.com-hemes
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_hermes
IdentitiesOnly yes
EOF
cat ~/.ssh/id_ed25519_hermes.pub
ssh -T git@github.com-hemes
source ~/.env
echo "$GITHUB_TOKEN" | gh auth login --with-token
cd ~/Development/my-project
gh repo create adityahimaone/my-project --public --source=. --remote=origin --push
SSH Config for Multiple Keys
If you have multiple SSH keys:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
Host github.com-hemes
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_hermes
IdentitiesOnly yes
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_work
IdentitiesOnly yes
Usage:
git clone git@github.com:personal/repo.git
git clone git@github.com-hemes:hermes/repo.git
git clone git@github.com-work:work/repo.git
Troubleshooting
Permission Denied (publickey)
ssh -vT git@github.com 2>&1 | grep "Offering"
ssh -T git@github.com-hemes
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519_hermes
gh CLI: "You are not logged into any GitHub hosts"
source ~/.env
echo "$GITHUB_TOKEN" | gh auth login --with-token
GraphQL: "Name already exists on this account"
git remote set-url origin git@github.com-hemes:adityahimaone/repo-name.git
git push -u origin main
gh repo view adityahimaone/repo-name
cd /path/to/repo
gh repo create adityahimaone/repo-name --public --source=. --remote=origin --push
git push -u origin main
gh CLI: "cannot use --web with --json"
echo "https://github.com/adityahimaone/repo-name"
gh repo view adityahimaone/repo-name
gh auth status shows "keyring" but no token
echo "$GITHUB_TOKEN" | gh auth login --with-token
Wrong Key Being Used
cat ~/.ssh/config
ssh -i ~/.ssh/id_ed25519_hermes -T git@github.com
git remote set-url origin git@github.com-hemes:user/repo.git
Files
~/.ssh/id_ed25519_hermes # Private key (NEVER share)
~/.ssh/id_ed25519_hermes.pub # Public key (add to GitHub)
~/.ssh/config # SSH configuration
Security Best Practices
- ✅ Use Ed25519 keys (more secure than RSA)
- ✅ Create dedicated keys per purpose (Hermes, work, personal)
- ✅ Use meaningful key comments (
-C "hermes-agent@username")
- ✅ Don't use passphrases for automated agents (or use ssh-agent)
- ❌ Never commit private keys
- ❌ Never share private keys
- ❌ Never store tokens in code (use env vars or gh auth)
Created: 2026-04-13
Context: Setting up GitHub access for Hermes Agent backup repository