agentleFS
18798aa1218798aa12/claude-code-skills/skills/networking/ssh-persist/SKILL.md

ssh-persist

Skill1 starsChanged 6 months agoMITView on GitHub

Automated SSH key deployment and persistent connection management. Auto-detects and fixes permission issues, immutable flags, and connection problems.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When this skill is triggered, Claude should automatically handle the entire process:

    line 22
  2. Distinctive:

    If previous password attempts triggered fail2ban:

    line 99
  3. Distinctive:

    After fixing, key-based auth prevents future lockouts (no failed password attempts).

    line 106

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

Automates SSH key-based authentication setup and optimizes connection reliability. Automatically detects and fixes common SSH issues.

When to use

  • First time connecting to a new server
  • SSH keeps asking for password
  • Connections frequently drop or timeout
  • Getting locked out by fail2ban

Auto-Setup Flow

When this skill is triggered, Claude should automatically handle the entire process:

Step 1: Check/Generate SSH Key

# Check existing key
if [ -f ~/.ssh/id_ed25519.pub ]; then
    echo "Key exists"
    cat ~/.ssh/id_ed25519.pub
else
    ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N "" -C "$(whoami)@$(hostname)"
fi

Step 2: Deploy Key to Server (with auto-fix)

# Try standard method first
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server 2>&1

# If that fails, try manual method
cat ~/.ssh/id_ed25519.pub | ssh user@server "cat >> ~/.ssh/authorized_keys" 2>&1

Auto-Fix: Permission Denied on authorized_keys

# Check file attributes
ssh user@server "lsattr ~/.ssh/authorized_keys 2>/dev/null"
# If immutable flag (i) is set:
ssh user@server "echo 'PASSWORD' | sudo -S chattr -i ~/.ssh/authorized_keys"
# Write key
PUB=$(cat ~/.ssh/id_ed25519.pub)
ssh user@server "echo '$PUB' >> ~/.ssh/authorized_keys"
# Restore immutable
ssh user@server "echo 'PASSWORD' | sudo -S chattr +i ~/.ssh/authorized_keys"

Auto-Fix: Wrong Owner on .ssh Directory

# Check ownership
ssh user@server "ls -la ~/.ssh/"
# If owned by different user:
ssh user@server "echo 'PASSWORD' | sudo -S chown user:user ~/.ssh ~/.ssh/authorized_keys"

Auto-Fix: Wrong Permissions

ssh user@server "chmod 700 ~/.ssh; chmod 600 ~/.ssh/authorized_keys"

Step 3: Configure SSH Config

# Check if host already configured
grep -q "Host ALIAS" ~/.ssh/config 2>/dev/null

# Add or update config
cat >> ~/.ssh/config << EOF
Host ALIAS
    HostName SERVER_IP
    User USERNAME
    IdentityFile ~/.ssh/id_ed25519
    ServerAliveInterval 15
    ServerAliveCountMax 20
    ConnectTimeout 30
    TCPKeepAlive yes
EOF

Step 4: Verify

# Test passwordless connection
ssh ALIAS "echo 'Key auth OK'; hostname"

# Measure speed
time ssh ALIAS "echo connected"

Auto-Fix: fail2ban Lockout

If previous password attempts triggered fail2ban:

# Wait 30-60 minutes for auto-unban
# Or if you have sudo on the server via another path:
ssh other-user@server "sudo fail2ban-client set sshd unbanip YOUR_IP"

After fixing, key-based auth prevents future lockouts (no failed password attempts).

Configuration Reference

Host <alias>
    HostName <ip>              # Server IP or domain
    User <username>            # SSH username
    Port <port>                # Default: 22
    IdentityFile <key>         # Private key path
    ServerAliveInterval 15     # Keepalive interval (seconds)
    ServerAliveCountMax 20     # Max missed keepalives
    ConnectTimeout 30          # Connection timeout
    TCPKeepAlive yes           # TCP keepalive

    # Linux/macOS only:
    ControlMaster auto
    ControlPath ~/.ssh/cm-%r@%h:%p
    ControlPersist 4h

Platform Notes

FeatureLinux/macOSWindows
Key authFullFull
ControlMasterFull (~0.1s)Not supported
KeepaliveFullFull
Speed~0.1s reuse / ~2s new~3-4s

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.