ssh-remote
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSSH Remote Access
SSH远程访问
Overview
概述
SSH (Secure Shell) provides encrypted remote access, file transfer, and tunneling over untrusted networks. OpenSSH is the standard implementation on Linux, macOS, and Windows (via built-in client). The client configuration lives at and supports per-host settings, identity management, and connection reuse.
~/.ssh/configWhen to use: Remote server management, secure file transfers, port forwarding, jump host traversal, automated deployments, SOCKS proxying.
When NOT to use: High-throughput bulk data transfer across WANs (use Globus or similar), GUI-heavy remote desktop (use VNC/RDP), container orchestration (use kubectl/docker CLI).
SSH(Secure Shell)可在不可信网络上提供加密的远程访问、文件传输和隧道功能。OpenSSH是Linux、macOS和Windows(通过内置客户端)上的标准实现。客户端配置位于,支持按主机设置、身份管理和连接复用。
~/.ssh/config适用场景: 远程服务器管理、安全文件传输、端口转发、跳转主机遍历、自动化部署、SOCKS代理。
不适用场景: 跨广域网的高吞吐量批量数据传输(使用Globus或类似工具)、GUI密集型远程桌面(使用VNC/RDP)、容器编排(使用kubectl/docker CLI)。
Quick Reference
快速参考
| Pattern | Command / Directive | Key Points |
|---|---|---|
| Basic connect | | Add |
| Identity file | | Specify private key explicitly |
| Remote command | | Add |
| SSH config alias | | Simplifies repeated connections |
| File copy (rsync) | | Preferred over scp for all transfers |
| File copy (scp) | | Legacy protocol; uses SFTP internally |
| Local tunnel | | Access remote services locally |
| Remote tunnel | | Expose local services to remote |
| SOCKS proxy | | Dynamic port forwarding |
| Jump host | | ProxyJump, available since OpenSSH 7.3 |
| Key generation | | Ed25519 recommended for all new keys |
| FIDO2 key | | Hardware-backed, requires OpenSSH 8.2+ |
| Agent | | Cache key passphrase for session |
| Multiplexing | | Reuse TCP connections across sessions |
| Debug | | Up to |
| 模式 | 命令/指令 | 核心要点 |
|---|---|---|
| 基础连接 | | 非默认端口需添加 |
| 身份文件 | | 显式指定私钥 |
| 远程命令 | | 交互式命令需添加 |
| SSH配置别名 | | 简化重复连接 |
| 文件复制(rsync) | | 所有传输场景优先使用,优于scp |
| 文件复制(scp) | | 旧版协议;内部使用SFTP |
| 本地隧道 | | 本地访问远程服务 |
| 远程隧道 | | 向远程暴露本地服务 |
| SOCKS代理 | | 动态端口转发 |
| 跳转主机 | | ProxyJump,OpenSSH 7.3及以上版本支持 |
| 密钥生成 | | 所有新密钥推荐使用Ed25519 |
| FIDO2密钥 | | 硬件加密,需OpenSSH 8.2+版本支持 |
| 代理 | | 会话期间缓存密钥密码 |
| 多路复用 | 配置中添加 | 跨会话复用TCP连接 |
| 调试 | | 最多可使用 |
Key Type Recommendations
密钥类型推荐
| Algorithm | Recommendation | Notes |
|---|---|---|
| Ed25519 | Default for all new keys | 256-bit, fast, secure, supported on OpenSSH 6.5+ |
| Ed25519-SK (FIDO2) | Strongest option with hardware key | Requires physical security key, OpenSSH 8.2+ |
| RSA 4096 | Legacy compatibility only | Use only when Ed25519 is unsupported by the remote system |
| ECDSA | Avoid | Implementation concerns; prefer Ed25519 |
| 算法 | 推荐方案 | 说明 |
|---|---|---|
| Ed25519 | 所有新密钥的默认选择 | 256位,快速、安全,OpenSSH 6.5+版本支持 |
| Ed25519-SK(FIDO2) | 搭配硬件密钥的最强选项 | 需要物理安全密钥,OpenSSH 8.2+版本支持 |
| RSA 4096 | 仅用于旧版兼容性场景 | 仅当远程系统不支持Ed25519时使用 |
| ECDSA | 避免使用 | 存在实现问题;优先选择Ed25519 |
File Transfer Decision Guide
文件传输决策指南
| Scenario | Tool | Why |
|---|---|---|
| Recurring syncs or large directories | | Delta sync, compression, resume, progress |
| Quick one-off file copy | | scp is simpler; rsync is more capable |
| Interactive file browsing | | Tab completion, directory navigation |
| High-bandwidth WAN transfers | Specialized tools (Globus) | SSH buffer limits reduce WAN throughput |
| 场景 | 工具 | 原因 |
|---|---|---|
| 定期同步或大型目录传输 | | 增量同步、压缩、断点续传、进度显示 |
| 快速单次文件复制 | | scp更简单;rsync功能更强大 |
| 交互式文件浏览 | | 支持Tab补全、目录导航 |
| 高带宽广域网传输 | 专用工具(如Globus) | SSH缓冲区限制会降低广域网吞吐量 |
Common Mistakes
常见错误
| Mistake | Correct Pattern |
|---|---|
| Using RSA keys for new setups | Generate Ed25519 keys -- faster, smaller, and equally secure |
Using | Use |
| Typing passphrase repeatedly during sessions | Use |
| Connecting through multiple hops with nested SSH | Use |
Running interactive commands without | Use |
Using | Use ProxyJump instead -- agent forwarding exposes keys to compromised hosts |
Setting | Include all three tokens to ensure unique sockets per connection |
| Disabling host key checking globally | Only use |
Not using | Prevents offering every loaded key to every server |
| 错误 | 正确做法 |
|---|---|
| 新部署使用RSA密钥 | 生成Ed25519密钥——更快、体积更小且安全性相当 |
大型或定期传输使用 | 使用 |
| 会话中重复输入密码 | 使用 |
| 通过嵌套SSH连接多跳主机 | 使用 |
运行交互式命令时不加 | 使用 |
在不可信主机上启用 | 改用ProxyJump——代理转发会将密钥暴露给已被攻陷的主机 |
设置 | 包含这三个令牌以确保每个连接的套接字唯一 |
| 全局禁用主机密钥检查 | 仅在可信的临时环境中使用 |
未使用 | 避免向每个服务器提供所有已加载的密钥 |
Security Checklist
安全检查清单
- Generate Ed25519 keys with strong passphrases
- Set on servers
PasswordAuthentication no - Set or
PermitRootLogin prohibit-passwordno - Use in client config
IdentitiesOnly yes - Restrict keys with and
command=infrom=authorized_keys - Use FIDO2 hardware keys () for high-security environments
ed25519-sk - Install on servers to block brute-force attempts
fail2ban - Consider SSH certificate authentication for fleet management
- 使用强密码生成Ed25519密钥
- 在服务器上设置
PasswordAuthentication no - 设置或
PermitRootLogin prohibit-passwordno - 在客户端配置中使用
IdentitiesOnly yes - 在中通过
authorized_keys和command=限制密钥使用from= - 高安全环境使用FIDO2硬件密钥()
ed25519-sk - 在服务器上安装以阻止暴力破解尝试
fail2ban - 考虑使用SSH证书认证进行集群管理
Delegation
任务分工
- Server inventory discovery and connection testing: Use agent
Explore - Multi-host deployment or bulk file transfers: Use agent
Task - Network architecture and bastion host planning: Use agent
Plan
- 服务器清单发现与连接测试:使用agent
Explore - 多主机部署或批量文件传输:使用agent
Task - 网络架构与堡垒机规划:使用agent
Plan
References
参考资料
- Connections, SSH config, and remote commands
- File transfers with rsync and scp
- Port forwarding, SOCKS proxy, and jump hosts
- Key management, FIDO2 keys, agent, and security hardening
- 连接、SSH配置与远程命令
- 基于rsync和scp的文件传输
- 端口转发、SOCKS代理与跳转主机
- 密钥管理、FIDO2密钥、代理与安全加固