agentleFS
yuchenmiao04yuchenmiao04/My_skills/skills/engineering/github-ssh-key-push/SKILL.md

github-ssh-key-push

Skill8 starsChanged 5 months agoMITView on GitHub

Push a local git repository to GitHub through a dedicated SSH key. Use when GitHub HTTPS push fails, SSH auth is missing, the user needs a public key to paste into GitHub, or a repo must be pushed with GIT_SSH_COMMAND and a specific identity file.

  • Reads credentials
  • Commits and pushes

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 8 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never print, paste, commit, upload, or summarize the private key file.

    line 10
  2. Distinctive:

    Do not modify unrelated project files to make push easier.

    line 11
  3. Very specific:

    Use a repository-specific key name when possible, for example ~/.ssh/<repo>_github_ed25519.

    line 12
  4. Very specific:

    Prefer --force-with-lease over --force when replacing an empty GitHub initialization commit.

    line 13
  5. Distinctive:

    Before pushing, run git status --short and explain any real uncommitted changes.

    line 14
  6. Distinctive:

    Create a dedicated SSH key only if it does not already exist:

    line 24
  7. Distinctive:

    After the user confirms the key was added, test authentication with the identity file:

    line 44
  8. Distinctive:

    If the GitHub repo contains an initialization commit that is safe to replace, fetch it first:

    line 65
  9. Distinctive:

    Use a normal push instead when the remote is empty or when preserving remote history:

    line 77
  10. Distinctive:

    Verify the remote branch:

    line 83
  11. Distinctive:

    If the public key was added as a deploy key with read-only access, enable write access or add it under account SSH keys.

    line 94

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

GitHub SSH Key Push

Safety Rules

  • Never print, paste, commit, upload, or summarize the private key file. Only show the .pub public key.
  • Do not modify unrelated project files to make push easier. In particular, do not compress, rename, or convert screenshots/assets unless the user explicitly asks.
  • Use a repository-specific key name when possible, for example ~/.ssh/<repo>_github_ed25519.
  • Prefer --force-with-lease over --force when replacing an empty GitHub initialization commit.
  • Before pushing, run git status --short and explain any real uncommitted changes.

Workflow

  1. Confirm the GitHub remote target, preferably SSH form:
git@github.com:OWNER/REPO.git
  1. Create a dedicated SSH key only if it does not already exist:
mkdir -p ~/.ssh
chmod 700 ~/.ssh
KEY="$HOME/.ssh/REPO_github_ed25519"
if [ ! -f "$KEY" ]; then
  ssh-keygen -t ed25519 -C "OWNER-REPO" -f "$KEY" -N ""
fi
chmod 600 "$KEY"
chmod 644 "$KEY.pub"
cat "$KEY.pub"

Tell the user to add the printed public key in GitHub:

  • Title: repository or machine name
  • Key type: Authentication Key
  • Key: the whole single ssh-ed25519 ... line
  1. After the user confirms the key was added, test authentication with the identity file:
ssh -i "$KEY" -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new -T git@github.com

Successful auth usually exits nonzero but prints:

Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.
  1. Configure the remote and verify local state:
git remote add origin git@github.com:OWNER/REPO.git 2>/dev/null || git remote set-url origin git@github.com:OWNER/REPO.git
git branch -M main
git status --short
git log --oneline -1 --decorate
  1. If the GitHub repo contains an initialization commit that is safe to replace, fetch it first:
GIT_SSH_COMMAND="ssh -i $KEY -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new" git fetch origin main
  1. Push with the dedicated key:
GIT_SSH_COMMAND="ssh -i $KEY -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new" git push -u origin main --force-with-lease

Use a normal push instead when the remote is empty or when preserving remote history:

GIT_SSH_COMMAND="ssh -i $KEY -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new" git push -u origin main
  1. Verify the remote branch:
GIT_SSH_COMMAND="ssh -i $KEY -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new" git ls-remote origin refs/heads/main

Troubleshooting

  • Permission denied (publickey): wrong key file, key not added to GitHub, or GitHub account lacks repo access.
  • could not read Username for 'https://github.com': remote is HTTPS or no credential helper is available; switch to SSH remote.
  • stale info with --force-with-lease: run git fetch origin main and retry after confirming the remote commit is safe to replace.
  • If the public key was added as a deploy key with read-only access, enable write access or add it under account SSH keys.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.