SSH Key-Based Authentication
БесплатноБез исполняемых скриптовНе проверенThis skill should be used when the user asks to "configure SSH key authentication", "set up SSH keys", "generate SSH key pairs", "copy SSH keys to servers"…
Об этом скилле
SSH Key-Based Authentication
Purpose
Implement secure SSH key-based authentication for remote server access. This skill covers generating cryptographic key pairs, deploying public keys to servers, configuring SSH clients for multiple servers, and applying security best practices. Essential for DevOps automation, secure system administration, and eliminating password-based authentication vulnerabilities.
Prerequisites
- Access to client and server systems with SSH installed
- User account on remote server with home directory access
- Terminal or command-line interface familiarity
- Understanding of file permissions concepts
- Root or sudo access for server-side configuration (optional)
Outputs and Deliverables
- Generated RSA/ED25519 SSH key pairs
- Configured remote server authorized_keys file
- SSH client configuration file for multiple servers
- Secure passwordless authentication setup
- Documentation of key management procedures
Core Workflow
Phase 1: Understand SSH Key Architecture
Master the fundamentals of SSH key-based authentication:
Key Pair Components
| Component | Location | Purpose | Security |
|---|---|---|---|
| Private Key | Client: ~/.ssh/id_rsa | Proves identity | MUST remain secret |
| Public Key | Server: ~/.ssh/authorized_keys | Verifies identity | Can be shared freely |
Why Keys Over Passwords
- Enhanced Security: Private keys are cryptographically strong (2048-4096 bits)
- Brute Force Resistant: Practically impossible to guess key values
- Automation Ready: Enables scripted/CI/CD server access
- Convenience: No password entry required after setup
- Audit Trail: Keys can be individually tracked and revoked
Key Algorithms
# RSA - widely compatible, use 4096 bits
ssh-keygen -t rsa -b 4096
# ED25519 - modern, smaller, faster (recommended)
ssh-keygen -t ed25519
# ECDSA - elliptic curve alternative
ssh-keygen -t ecdsa -b 521
Phase 2: Generate SSH Key Pairs
Create cryptographic key pairs on the client machine:
Standard Key Generation
# Generate RSA 4096-bit key with email identifier
ssh-keygen -t rsa -b 4096 -C "[email protected]"
# Interactive prompts:
# 1. File location: Press Enter for default (~/.ssh/id_rsa)
# 2. Passphrase: Enter strong passphrase (recommended)
Advanced Key Generation Options
# Generate ED25519 key (modern, recommended)
ssh-keygen -t ed25519 -C "user@hostname" -f ~/.ssh/myserver_ed25519
# Generate key with specific filename
ssh-keygen -t rsa -b 4096 -f ~/.ssh/production_key -C "production-access"
# Generate key without passphrase (automation only)
ssh-keygen -t ed25519 -N "" -f ~/.ssh/automation_key -C "automation"
Parameter Reference
| Option | Description | Example |
|---|---|---|
| -t | Key type (rsa, ed25519, ecdsa) | -t ed25519 |
| -b | Key bits (RSA: 2048/4096) | -b 4096 |
| -C | Comment (identifier) | -C "admin@server" |
| -f | Output filename | -f ~/.ssh/mykey |
| -N | New passphrase | -N "passphrase" |
| -p | Change passphrase | ssh-keygen -p -f keyfile |
Generated Files
~/.ssh/id_rsa # Private key (PROTECT THIS)
~/.ssh/id_rsa.pub # Public key (share with servers)
Phase 3: Deploy Public Keys to Servers
Install public key on remote servers for authentication:
Method 1: ssh-copy-id (Recommended)
# Copy public key to remote server
ssh-copy-id username@remote_server
# Specify a particular key
ssh-copy-id -i ~/.ssh/mykey.pub username@remote_server
# Use non-standard port
ssh-copy-id -p 2222 username@remote_server
Method 2: Manual Installation
# Display public key on client
cat ~/.ssh/id_rsa.pub
# On remote server, add to authorized_keys
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "ssh-rsa AAAA..." >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
Method 3: One-liner (pipe method)
# Combine into single command
cat ~/.ssh/id_rsa.pub | ssh username@server "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
Verify Deployment
# Test key-based authentication
ssh username@remote_server
# Verify with verbose output
ssh -v username@remote_server
Phase 4: Configure SSH Client
Streamline connections with SSH config file:
Create Configuration File
# Edit or create SSH config
nano ~/.ssh/config
# Set proper permissions
chmod 600 ~/.ssh/config
Basic Configuration Example
# Production Web Server
Host prod-web
HostName 192.168.1.100
User admin
IdentityFile ~/.ssh/production_key
Port 22
# Development Server
Host dev
HostName dev.example.com
User developer
IdentityFile ~/.ssh/dev_key
Port 2222
# Jump Host Configuration
Host bastion
HostName bastion.example.com
User jumpuser
IdentityFile ~/.ssh/bastion_key
Host internal-*
ProxyJump bastion
User admin
IdentityFile ~/.ssh/interna
Установить SSH Key-Based Authentication в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл SSH Key-Based Authentication?
This skill should be used when the user asks to "configure SSH key authentication", "set up SSH keys", "generate SSH key pairs", "copy SSH keys to servers", "configure SSH config file", "troubleshoot SSH key access", "manage multiple SSH keys", "restrict SSH key usage", "secure SSH access", or "automate SSH connections". Use this skill to implement secure, passwordless SSH authentication using cryptographic key pairs.
Как установить скилл SSH Key-Based Authentication?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл SSH Key-Based Authentication запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic