| name | github-auth |
| description | Set up GitHub auth via gh CLI, HTTPS token, or SSH. |
| stack | vcs |
| tags | ["github","auth","gh","git","ssh","token"] |
GitHub Auth
When to use
Any GitHub work before PRs, issues, authenticated clone, or API calls.
Tools
bash for gh, git, ssh, curl
- Never print full tokens. Prefer existence checks.
Detection (run first)
git --version
command -v gh >/dev/null && gh --version || echo "gh not installed"
gh auth status 2>/dev/null || echo "gh not authenticated"
test -n "${GH_TOKEN:-${GITHUB_TOKEN:-}}" && echo "token env set" || echo "no GH_TOKEN/GITHUB_TOKEN"
Decision:
gh auth status OK → use gh for everything
gh installed, not authed → Method A
- no
gh → Method B (git + token) or Method C (SSH)
Method A — gh CLI (preferred)
gh auth login -h github.com -p https -w
gh auth status
gh api user --jq .login
Useful scopes: repo, read:org, workflow (Actions), gist optional.
Method B — git HTTPS + PAT
User creates classic PAT at https://github.com/settings/tokens
Scopes: repo (+ workflow if Actions, read:org for org repos).
git config --global credential.helper store
git ls-remote https://github.com/<user>/<repo>.git
Env fallback for API without gh:
: "${GITHUB_TOKEN:=${GH_TOKEN:-}}"
curl -sS -H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/user
Method C — SSH
test -f ~/.ssh/id_ed25519.pub || ssh-keygen -t ed25519 -C "porcupine" -f ~/.ssh/id_ed25519 -N ""
cat ~/.ssh/id_ed25519.pub
ssh -T git@github.com
git remote set-url origin git@github.com:OWNER/REPO.git
Porcupine notes
- Shell tool is
bash (not Hermes terminal)
- Agent home:
~/.porcupine/agent/ (not ~/.hermes)
- Do not write tokens into skills, PROMPT.md, or chat logs
Verify
gh auth status 2>/dev/null || true
git ls-remote origin HEAD 2>/dev/null | head -1