agentleFS
RichardGeorgeDavisRichardGeorgeDavis/Codex-Workspace/.agents/skills/ssh-keychain-access/SKILL.md

ssh-keychain-access

Skill2 starsChanged 56 days agoMITView on GitHub

Use when helping establish SSH access through macOS Keychain credentials, especially emergency root SSH, password-to-key bootstrap, authorized_keys repair, or adding SSH private keys to the Apple keychain.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 9 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    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. Distinctive:

    Use this skill for SSH access recovery where credentials are in macOS Keychain.

    line 8
  2. Very specific:

    Prefer SSH keys loaded with ssh-add --apple-use-keychain.

    line 12
  3. Distinctive:

    Use a Keychain-stored password only as an emergency fallback or to bootstrap key-based access.

    line 13
  4. Distinctive:

    Never print passwords, private keys, API keys, WHM credentials, or licence credentials.

    line 14
  5. Very specific:

    Do not run security find-generic-password -w ...

    line 15
  6. Very specific:

    Do not use sshpass -p, put passwords in command history, or disable host key checking.

    line 16
  7. Distinctive:

    Add the private key to the macOS keychain:

    line 27
  8. Distinctive:

    Test SSH with public-key auth:

    line 34
  9. Distinctive:

    Run this only in the user's local terminal.

    line 42
  10. Distinctive:

    Verify the item exists without printing the password:

    line 59
  11. Distinctive:

    Use the bundled helper when password SSH is required and the password must come from Keychain without appearing in output:

    line 67
  12. Distinctive:

    If password access works, use it only long enough to install a public key:

    line 96

≈ “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

SSH Keychain Access

Use this skill for SSH access recovery where credentials are in macOS Keychain.

Security stance

  • Prefer SSH keys loaded with ssh-add --apple-use-keychain.
  • Use a Keychain-stored password only as an emergency fallback or to bootstrap key-based access.
  • Never print passwords, private keys, API keys, WHM credentials, or licence credentials.
  • Do not run security find-generic-password -w ... as a standalone command that would expose the password in tool output.
  • Do not use sshpass -p, put passwords in command history, or disable host key checking.
  • For root SSH, narrow the target to the specific host/IP and remove temporary access when recovery is complete.

Key-first workflow

  1. Check loaded identities:

    ssh-add -l
  2. Add the private key to the macOS keychain:

    chmod 600 /path/to/private_key
    ssh-add --apple-use-keychain /path/to/private_key
  3. Test SSH with public-key auth:

    ssh -o PreferredAuthentications=publickey user@host

Store a password in Keychain

Run this only in the user's local terminal. It avoids placing the password in shell history:

SERVICE="example-server-ssh"
ACCOUNT="admin@example-host"
printf 'Password for %s: ' "$ACCOUNT"
OLD_STTY=$(stty -g)
trap 'stty "$OLD_STTY"; unset SSH_PASSWORD' INT TERM EXIT
stty -echo
IFS= read -r SSH_PASSWORD
stty "$OLD_STTY"
printf '\n'
security add-generic-password -U -a "$ACCOUNT" -s "$SERVICE" -w "$SSH_PASSWORD"
unset SSH_PASSWORD
trap - INT TERM EXIT

Verify the item exists without printing the password:

security find-generic-password -a "$ACCOUNT" -s "$SERVICE"

Use the helper

Use the bundled helper when password SSH is required and the password must come from Keychain without appearing in output:

shared/skills/ssh-keychain-access/scripts/ssh-keychain-login.sh \
  --host example-host \
  --user admin \
  --service example-server-ssh \
  --account admin@example-host

For an unknown host key, verify the expected server host key out of band first. Only then re-run with:

--accept-new-host-key

To run a one-off remote command, append it after --:

shared/skills/ssh-keychain-access/scripts/ssh-keychain-login.sh \
  --host example-host \
  --user admin \
  --service example-server-ssh \
  --account admin@example-host \
  -- 'hostname; whoami'

Bootstrap public-key access

If password access works, use it only long enough to install a public key:

ssh-keygen -t ed25519 -a 100 -f ~/.ssh/codex-whm-recovery-$(date +%Y-%m-%d) -C "codex-whm-recovery-$(date +%Y-%m-%d)"
ssh-add --apple-use-keychain ~/.ssh/codex-whm-recovery-$(date +%Y-%m-%d)
cat ~/.ssh/codex-whm-recovery-$(date +%Y-%m-%d).pub

Then append only the public key to the server's authorized_keys, confirm public-key login works, and prefer key login for the rest of the session.

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.