📄 SKILL.md

← Vault

name: github-auth

description: Set up GitHub authentication for the agent using git (universally available) or the gh CLI. Covers HTTPS tokens, SSH keys, credential helpers, and gh auth — with a detection flow to pick the right method automatically.

version: 1.1.0

author: Hermes Agent

license: MIT

metadata:

hermes:

tags: [GitHub, Authentication, Git, gh-cli, SSH, Setup]

related_skills: [github-pr-workflow, github-code-review, github-issues, github-repo-management]


GitHub Authentication Setup

This skill sets up authentication so the agent can work with GitHub repositories, PRs, issues, and CI. It covers two paths:

Step 3: Test the connection

`bash

ssh -T git@github.com

Expected: "Hi ! You've successfully authenticated..."

`

Step 4: Configure git to use SSH for GitHub

`bash

Rewrite HTTPS GitHub URLs to SSH automatically

git config --global url."git@github.com:".insteadOf "https://github.com/"

`

Step 5: Configure git identity

`bash

git config --global user.name "Their Name"

git config --global user.email "their-email@example.com"

`


Method 2: gh CLI Authentication

If gh is installed, it handles both API access and git credentials in one step.

Interactive Browser Login (Desktop)

`bash

gh auth login

Select: GitHub.com

Select: HTTPS

Authenticate via browser

`

Token-Based Login (Headless / SSH Servers)

`bash

echo "" | gh auth login --with-token

Set up git credentials through gh

gh auth setup-git

`

Verify

`bash

gh auth status

`


Using the GitHub API Without gh

When gh is not available, you can still access the full GitHub API using curl with a personal access token. This is how the other GitHub skills implement their fallbacks.

Setting the Token for API Calls

`bash

Option 1: Export as env var (preferred — keeps it out of commands)

export GITHUB_TOKEN=""

Then use in curl calls:

curl -s -H "Authorization: token $GITHUB_TOKEN" \

https://api.github.com/user

`

Extracting the Token from Git Credentials

If git credentials are already configured (via credential.helper store), the token can be extracted:

`bash

Read from git credential store

grep "github.com" ~/.git-credentials 2>/dev/null | head -1 | sed 's|https://[^:]:\([^@]\)@.*|\1|'

`

Helper: Detect Auth Method

Use this pattern at the start of any GitHub workflow:

`bash

Try gh first, fall back to git + curl

if command -v gh &>/dev/null && gh auth status &>/dev/null; then

echo "AUTH_METHOD=gh"

elif [ -n "$GITHUB_TOKEN" ]; then

echo "AUTH_METHOD=curl"

elif [ -f ~/.hermes/.env ] && grep -q "^GITHUB_TOKEN=" ~/.hermes/.env; then

export GITHUB_TOKEN=$(grep "^GITHUB_TOKEN=" ~/.hermes/.env | head -1 | cut -d= -f2 | tr -d '\n\r')

echo "AUTH_METHOD=curl"

elif grep -q "github.com" ~/.git-credentials 2>/dev/null; then

export GITHUB_TOKEN=$(grep "github.com" ~/.git-credentials | head -1 | sed 's|https://[^:]:\([^@]\)@.*|\1|')

echo "AUTH_METHOD=curl"

else

echo "AUTH_METHOD=none"

echo "Need to set up authentication first"

fi

`


Troubleshooting

ProblemSolution
-------------------
git push asks for passwordGitHub disabled password auth. Use a personal access token as the password, or switch to SSH
remote: Permission to X deniedToken may lack repo scope — regenerate with correct scopes
fatal: Authentication failedCached credentials may be stale — run git credential reject then re-authenticate
ssh: connect to host github.com port 22: Connection refusedTry SSH over HTTPS port: add Host github.com with Port 443 and Hostname ssh.github.com to ~/.ssh/config
Credentials not persistingCheck git config --global credential.helper — must be store or cache
Multiple GitHub accountsUse SSH with different keys per host alias in ~/.ssh/config, or per-repo credential URLs
gh: command not found + no sudoUse git-only Method 1 above — no installation needed