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
In this repository10 other files it gives its agents.
- claude-code-statuslineSkill
- macos-accessibilitySkill
- remote-guiSkill
- cf-auto-checkinSkill
- cf-pages-deploySkill
- cloudflare-tunnelSkill
- lark-imSkill
- proxy-multi-platformSkill
- tailscale-meshSkill
- vps-singboxSkill
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
- Distinctive: line 22
When this skill is triggered, Claude should automatically handle the entire process:
- Distinctive: line 99
If previous password attempts triggered fail2ban:
- Distinctive: line 106
After fixing, key-based auth prevents future lockouts (no failed password attempts).
≈ “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
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)"
fiStep 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>&1Auto-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
EOFStep 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 4hPlatform Notes
| Feature | Linux/macOS | Windows |
| Key auth | Full | Full |
| ControlMaster | Full (~0.1s) | Not supported |
| Keepalive | Full | Full |
| Speed | ~0.1s reuse / ~2s new | ~3-4s |
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.

