ssh-configuration — скилл для Claude Code: что делает и как установить
Настраивает OpenSSH на клиенте и сервере, помогает выпускать ключи Ed25519, пробрасывать порты и поднимать бастион-хосты для безопасного удалённого доступа.
npx skills add BagelHole/DevOps-Security-Agent-Skills --skill ssh-configuration -a claude-codeЧто делает ssh-configuration
Скилл даёт готовые инструкции по работе с OpenSSH. Он подсказывает агенту, как сгенерировать ключи Ed25519 или RSA 4096, настроить ssh-agent, организовать ротацию ключей и прописать клиентские профили в ~/.ssh/config с мультиплексированием соединений через ControlMaster.
Для серверов собраны правила ужесточения /etc/ssh/sshd_config. Они отключают парольную аутентификацию, блокируют вход root, ограничивают шифры и изолируют пользователей SFTP в chroot-окружении. Если применить невалидный конфиг без проверки через sshd -t и без открытой запасной сессии, доступ к серверу будет потерян.
Также в состав входят сценарии для туннелирования портов, создания динамических SOCKS-прокси и связки бастион-хостов через директиву ProxyJump или флаг ssh -J.
Какие задачи решает
- запретить вход под root и парольную авторизацию в sshd_config
- настроить доступ к изолированной сети через бастион с ProxyJump
- выпустить пару ключей Ed25519 и скопировать их на сервер
- пробросить локальный порт к удалённой базе данных через SSH-туннель
- включить мультиплексирование ControlMaster для ускорения подключений
Примеры запросов агенту
- Сгенерируй ключ Ed25519 для deploy и скопируй его на сервер
- Настрой ~/.ssh/config для подключения к внутренней базе через bastion
- Подготовь защищённый sshd_config с отключённым парольным входом
Как установить ssh-configuration
1Через Skills CLI (Vercel)
npx skills add BagelHole/DevOps-Security-Agent-Skills --skill ssh-configuration -a claude-code2Вручную: положить файлы
~/.claude/skills/ssh-configuration/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/ssh-configuration/
1Через Skills CLI (Vercel)
npx skills add BagelHole/DevOps-Security-Agent-Skills --skill ssh-configuration -a codex2Вручную: положить файлы
.agents/skills/ssh-configuration/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add BagelHole/DevOps-Security-Agent-Skills --skill ssh-configuration -a cursor2Вручную: положить файлы
.cursor/skills/ssh-configuration/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install BagelHole/DevOps-Security-Agent-Skills ssh-configuration2Вручную: положить файлы
.github/skills/ssh-configuration/SKILL.md1Через Skills CLI (Vercel)
npx skills add BagelHole/DevOps-Security-Agent-Skills --skill ssh-configuration -a gemini-cli2Командой платформы
gemini skills install https://github.com/BagelHole/DevOps-Security-Agent-Skills --path infrastructure/servers/ssh-configurationВручную: положить файлы
.devin/skills/ssh-configuration/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add BagelHole/DevOps-Security-Agent-Skills --skill ssh-configuration -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Из того же набора127
Похожие
Рядом в теме «DevOps и инфраструктура»
Всё по теме «DevOps и инфраструктура» →Вопросы о ssh-configuration
Как установить ssh-configuration в Claude Code?
Выполните команду npx skills add BagelHole/DevOps-Security-Agent-Skills --skill ssh-configuration -a claude-code.
Что делает скилл ssh-configuration?
Он предоставляет инструкции по генерации ключей, туннелированию портов, настройке джамп-хостов и защите демона OpenSSH.
Что требуется на сервере для применения настроек sshd?
Нужны установленный пакет sshd, права root или sudo для редактирования /etc/ssh/sshd_config, а также открытый TCP-порт 22 или кастомный порт в фаерволе.
Исходный текст
SKILL.md · MIT
--- name: ssh-configuration description: Configure SSH servers and clients securely. Manage keys, tunnels, and config files. Use when setting up secure remote access. license: MIT metadata: author: devops-skills version: "1.0" --- # SSH Configuration Secure SSH server and client configuration for production environments, including key management, hardened sshd settings, bastion host architecture, tunneling, and multiplexing. ## When to Use - Setting up secure remote access to Linux or Unix servers - Hardening SSH daemon configuration to meet compliance requirements - Configuring bastion / jump hosts for private network access - Creating SSH tunnels for secure port forwarding - Managing SSH keys for teams or automated deployments - Troubleshooting connection, authentication, or performance issues ## Prerequisites - OpenSSH client installed locally (`ssh -V` to verify) - OpenSSH server installed on target (`sshd`) - Root or sudo access on the server for sshd_config changes - Firewall rules allowing TCP port 22 (or custom SSH port) ## Key Generation and Management ```bash # Generate an Ed25519 key (recommended -- fast, secure, short) ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/id_ed25519 # Generate an RSA 4096-bit key (for legacy compatibility) ssh-keygen -t rsa -b 4096 -C "[email protected]" -f ~/.ssh/id_rsa_legacy # Generate a key with a custom comment and no passphrase (CI/CD use only) ssh-keygen -t ed25519 -C "ci-deploy-key" -f ~/.ssh/ci_deploy -N "" # Copy public key to a remote server ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server # Manually append a public key (when ssh-copy-id is unavailable) cat ~/.ssh/id_ed25519.pub | ssh user@server "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys" # List fingerprints of keys on the agent ssh-add -l # Start the SSH agent and add a key eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519 # Add a key with a lifetime (auto-removed after 8 hours) ssh-add -t 28800 ~/.ssh/id_ed25519 # Remove all keys from the agent ssh-add -D # Convert an OpenSSH key to PEM format (for tools that need it) ssh-keygen -p -m PEM -f ~/.ssh/id_rsa_legacy # Show the public key fingerprint (SHA256) ssh-keygen -lf ~/.ssh/id_ed25519.pub # Rotate a key: generate new, deploy, then revoke old ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_new -C "[email protected] rotated $(date +%Y-%m)" ssh-copy-id -i ~/.ssh/id_ed25519_new.pub user@server # After verifying the new key works, remove the old public key from authorized_keys on the server ``` ## SSH Client Configuration (~/.ssh/config) ```text # Global defaults applied to all hosts Host * AddKeysToAgent yes IdentitiesOnly yes ServerAliveInterval 60 ServerAliveCountMax 3 TCPKeepAlive yes Compression yes # Production servers via bastion Host bastion HostName bastion.example.com User ops IdentityFile ~/.ssh/id_ed25519 Port 22 Host prod-web-* User deploy IdentityFile ~/.ssh/id_ed25519 ProxyJump bastion Port 22 Host prod-web-1 HostName 10.0.1.10 Host prod-web-2 HostName 10.0.1.11 # Staging accessed directly Host staging HostName staging.example.com User deploy IdentityFile ~/.ssh/id_ed25519_staging # Database tunnel through bastion Host db-tunnel HostName 10.0.2.50 User dba ProxyJump bastion LocalForward 5432 localhost:5432 # GitHub deploy key Host github-deploy HostName github.com User git IdentityFile ~/.ssh/github_deploy_key IdentitiesOnly yes # Connection multiplexing for faster repeated connections Host fast-* ControlMaster auto ControlPath ~/.ssh/sockets/%r@%h-%p ControlPersist 600 ``` ```bash # Create the sockets directory for multiplexing mkdir -p ~/.ssh/sockets chmod 700 ~/.ssh/sockets ``` ## Hardened Server Configuration (/etc/ssh/sshd_config) ```bash # /etc/ssh/sshd_config -- hardened configuration # ----------------------------------------------- # Listen on a non-default port (obscurity, not security -- combine with firewall) Port 22 # Protocol and key exchange Protocol 2 KexAlgorithms curve25519-sha256,[email protected],diffie-hellman-group16-sha512 Ciphers [email protected],[email protected],[email protected] MACs [email protected],[email protected] # Authentication PermitRootLogin no PasswordAuthentication no PubkeyAuthentication yes AuthenticationMethods publickey MaxAuthTries 3 MaxSessions 5 LoginGraceTime 30 # Restrict users and groups AllowGroups ssh-users ops-team # AllowUsers deploy admin # Disable unused authentication methods ChallengeResponseAuthentication no KerberosAuthentication no GSSAPIAuthentication no # Forwarding controls AllowTcpForwarding yes AllowAgentForwarding no X11Forwarding no PermitTunnel no # Security hardening ClientAliveInterval 300 ClientAliveCountMax 2 UsePAM yes UseDNS no PermitEmptyPasswords no PermitUserEnvironment no # Logging SyslogFacility AUTH LogLevel VERBOSE # SFTP subsystem Subsystem sftp /usr/lib/openssh/sftp-server -f AUTH -l INFO # Match block: restrict deploy user to SFTP only Match User sftponly ForceCommand internal-sftp ChrootDirectory /home/%u AllowTcpForwarding no AllowAgentForwarding no X11Forwarding no ``` ```bash # Validate configuration before restarting sshd -t # Restart sshd to apply changes systemctl restart sshd # Always keep an existing session open while testing # Open a NEW terminal to verify you can still connect before closing the old one ``` ## Bastion Host Setup ```bash # On the bastion server, restrict forwarding to internal subnets only # /etc/ssh/sshd_config addition on bastion: AllowTcpForwarding yes PermitOpen 10.0.0.0/8:22 10.0.0.0/8:5432 # Disable shell access for jump-only users Match User jump-user PermitTTY no ForceCommand /usr/sbin/nologin AllowTcpForwarding yes # Connect through the bastion from a client in one command ssh -J [email protected] [email protected] # Equivalent using ProxyCommand (older SSH versions) ssh -o ProxyCommand="ssh -W %h:%p [email protected]" [email protected] # Multi-hop: client -> bastion -> app-server -> db-server ssh -J ops@bastion,[email protected] [email protected] ``` ## SSH Tunneling ```bash # Local port forward: access remote service on localhost # Access remote PostgreSQL (10.0.2.50:5432) via bastion at localhost:5432 ssh -L 5432:10.0.2.50:5432 [email protected] -N # Remote port forward: expose local service to the remote network # Make local dev server (localhost:3000) available on server port 8080 ssh -R 8080:localhost:3000 user@server -N # Dynamic SOCKS proxy: route all traffic through the server ssh -D 1080 user@server -N # Then configure browser or apps to use SOCKS5 proxy at localhost:1080 # Tunnel with a background process ssh -fN -L 5432:10.0.2.50:5432 [email protected] # Find and kill the tunnel later ps aux | grep "ssh -fN" | grep -v grep kill <pid> # Autossh for persistent tunnels (auto-reconnects) autossh -M 0 -f -N -L 5432:10.0.2.50:5432 [email protected] \ -o "ServerAliveInterval=30" -o "ServerAliveCountMax=3" ``` ## Agent Forwarding (Use with Caution) ```bash # Enable agent forwarding for a single connection ssh -A user@bastion # From the bastion, your local keys are available to authenticate further ssh [email protected] # Uses your local key via the agent # SECURITY WARNING: Agent forwarding exposes your keys to anyone with root # on the intermediate host. Prefer ProxyJump instead. # Safer alternative: ProxyJump does not expose the agent ssh -J ops@bastion [email protected] ``` ## SSH Key Restrictions in authorized_keys ```text # Restrict a key to a specific command only (backup key) command="/usr/local/bin/run-backup.sh",no-port-forwarding,no-X11-forwarding,no-agent-forwarding ssh-ed25519 AAAA... [email protected] # Restrict a key to specific source IPs from="10.0.0.0/24,192.168.1.0/24" ssh-ed25519 AAAA... [email protected] # Read-only SFTP key with chroot command="internal-sftp",no-port-forwarding,no-pty ssh-ed25519 AAAA... [email protected] ``` ## Troubleshooting | Symptom | Diagnostic Command | Common Fix | |---|---|---| | Connection refused | `ss -tlnp \| grep 22` on server | Ensure sshd is running; check firewall rules | | Permission denied (publickey) | `ssh -vvv user@server` | Verify key is in authorized_keys, permissions 600/700 | | Host key verification failed | `ssh-keygen -R server` | Remove stale host key; verify server identity | | Connection timeout | `ssh -o ConnectTimeout=5 user@server` | Check network path, security groups, NACLs | | Slow SSH login | Check `UseDNS` in sshd_config | Set `UseDNS no`; check reverse DNS | | Broken pipe / dropped sessions | Add `ServerAliveInterval 60` to config | Configure keepalive on both client and server | | Agent forwarding not working | `ssh-add -l` on bastion | Ensure `-A` flag used and agent has keys loaded | | Tunnel port already in use | `ss -tlnp \| grep <port>` | Kill existing tunnel or use a different local port | ## Related Skills - `linux-administration` -- General Linux system administration - `user-management` -- Managing the users who connect via SSH - `systemd-services` -- Managing sshd as a systemd service - `performance-tuning` -- Network tuning for SSH performance
© devops-skills · MIT · BagelHole/DevOps-Security-Agent-Skills