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
In this repository58 other files it gives its agents.
- skills/writing-polish/humanizer/AGENTS.mdAGENTS.md
- frontend-designSkill
- ask-mattSkill
- codebase-designSkill
- code-reviewSkill
- diagnosing-bugsSkill
- domain-modelingSkill
- github-codex-keySkill
- implementSkill
- improve-codebase-architectureSkill
- prototypeSkill
- setup-matt-pocock-skillsSkill
- tddSkill
- to-issuesSkill
- to-prdSkill
- triageSkill
- huggingface-accelerateSkill
- quantizing-models-bitsandbytesSkill
- gpuboxSkill
- evaluating-llms-harnessSkill
- ml-training-recipesSkill
- peft-fine-tuningSkill
- experiment-tracking-swanlabSkill
- unslothSkill
- matlab-add-awgnSkill
- matlab-agentic-toolkit-setupSkill
- matlab-build-appSkill
- matlab-create-live-scriptSkill
- matlab-debuggingSkill
- matlab-design-digital-filterSkill
- matlab-display-imageSkill
- matlab-install-productsSkill
- matlab-list-productsSkill
- matlab-map-database-objectsSkill
- matlab-model-serdes-systemsSkill
- matlab-modernize-codeSkill
- matlab-read-databaseSkill
- matlab-review-codeSkill
- matlab-testingSkill
- matlab-use-duckdbSkill
- matlab-write-databaseSkill
- grillingSkill
- grill-meSkill
- grill-with-docsSkill
- handoffSkill
- teachSkill
- writing-great-skillsSkill
- ara-compilerSkill
- ara-research-managerSkill
- research-paper-notesSkill
- ara-rigor-reviewerSkill
- brainstorming-research-ideasSkill
- creative-thinking-for-researchSkill
- academic-plottingSkill
- ml-paper-writingSkill
- paper-spineSkill
- humanizerSkill
- prompt-optimizerSkill
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
- Very specific: line 10
Never print, paste, commit, upload, or summarize the private key file.
- Distinctive: line 11
Do not modify unrelated project files to make push easier.
- Very specific: line 12
Use a repository-specific key name when possible, for example ~/.ssh/<repo>_github_ed25519.
- Very specific: line 13
Prefer --force-with-lease over --force when replacing an empty GitHub initialization commit.
- Distinctive: line 14
Before pushing, run git status --short and explain any real uncommitted changes.
- Distinctive: line 24
Create a dedicated SSH key only if it does not already exist:
- Distinctive: line 44
After the user confirms the key was added, test authentication with the identity file:
- Distinctive: line 65
If the GitHub repo contains an initialization commit that is safe to replace, fetch it first:
- Distinctive: line 77
Use a normal push instead when the remote is empty or when preserving remote history:
- Distinctive: line 83
Verify the remote branch:
- Distinctive: line 94
If the public key was added as a deploy key with read-only access, enable write access or add it under account SSH keys.
≈ “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.
Files
GitHub SSH Key Push
Safety Rules
- Never print, paste, commit, upload, or summarize the private key file. Only show the
.pubpublic 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-leaseover--forcewhen replacing an empty GitHub initialization commit. - Before pushing, run
git status --shortand explain any real uncommitted changes.
Workflow
- Confirm the GitHub remote target, preferably SSH form:
git@github.com:OWNER/REPO.git- 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
- 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.comSuccessful auth usually exits nonzero but prints:
Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.- 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- 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- 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-leaseUse 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- Verify the remote branch:
GIT_SSH_COMMAND="ssh -i $KEY -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new" git ls-remote origin refs/heads/mainTroubleshooting
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 infowith--force-with-lease: rungit fetch origin mainand 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.
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
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.

