SSH 速查表
一份可搜索、可打印的 SSH 参考——连接、密钥、配置、隧道、SCP/SFTP 和 agent 转发。免费。
Connecting
10ssh user@host
Connect as user to host
ssh -p 2222 user@host
Connect on a non-default port
ssh -i ~/.ssh/id_ed25519 user@host
Use a specific identity key
ssh user@host 'uptime'
Run a single remote command and exit
ssh -v user@host
Verbose output for debugging (-vvv for more)
ssh -t user@host 'sudo -i'
Force a pseudo-terminal (for interactive cmds)
ssh -X user@host
Enable X11 forwarding
ssh -o ServerAliveInterval=60 user@host
Send keepalives to avoid timeouts
exit / Ctrl-D
Close the remote session
~.
Force-disconnect a frozen session
Key generation
8ssh-keygen -t ed25519 -C 'you@example.com'
Generate a modern Ed25519 key pair
ssh-keygen -t rsa -b 4096
Generate a 4096-bit RSA key pair
ssh-keygen -t ed25519 -f ~/.ssh/work
Write the key to a specific file
ssh-keygen -p -f ~/.ssh/id_ed25519
Change the passphrase of an existing key
ssh-keygen -y -f ~/.ssh/id_ed25519
Print the public key from a private key
ssh-keygen -l -f ~/.ssh/id_ed25519.pub
Show a key fingerprint
ssh-keygen -lv -f ~/.ssh/id_ed25519.pub
Show the fingerprint randomart image
ssh-keygen -R host
Remove a host key from known_hosts
Installing public keys
7ssh-copy-id user@host
Copy your default public key to the server
ssh-copy-id -i ~/.ssh/work.pub user@host
Copy a specific public key
ssh-copy-id -p 2222 user@host
Copy the key over a custom port
cat ~/.ssh/id_ed25519.pub | ssh user@host 'cat >> ~/.ssh/authorized_keys'
Manual copy when ssh-copy-id is missing
chmod 700 ~/.ssh
Correct permissions on the .ssh directory
chmod 600 ~/.ssh/authorized_keys
Correct permissions on authorized_keys
pbcopy < ~/.ssh/id_ed25519.pub
Copy public key to clipboard (macOS)
SSH config (~/.ssh/config)
10Host myserver
Alias: connect with `ssh myserver`
HostName 203.0.113.10
Real hostname or IP for the alias
User deploy
Default username for this host
Port 2222
Default port for this host
IdentityFile ~/.ssh/work
Key to use for this host
IdentitiesOnly yes
Only offer the listed key
ForwardAgent yes
Forward the SSH agent to this host
Host *.example.com
Wildcard match for a domain
Host *
Global defaults for all hosts
ServerAliveInterval 60
Keepalive interval for all hosts
Port forwarding / tunneling
7ssh -L 8080:localhost:80 user@host
Local: reach host:80 via local 8080
ssh -L 5432:db.internal:5432 user@host
Local forward to a third host through the server
ssh -R 9000:localhost:3000 user@host
Remote: expose your local 3000 as host:9000
ssh -D 1080 user@host
Dynamic: SOCKS proxy on local port 1080
ssh -N -L 8080:localhost:80 user@host
Tunnel only, do not run a remote shell
ssh -f -N -L 8080:localhost:80 user@host
Open the tunnel in the background
ssh -g -L 8080:localhost:80 user@host
Allow other hosts to use the local forward
Jump hosts / bastions
5ssh -J jump@bastion user@target
Hop through a bastion to reach the target
ssh -J h1,h2 user@target
Chain multiple jump hosts
ProxyJump bastion
Config equivalent of -J
ProxyCommand ssh -W %h:%p bastion
Older ProxyCommand-based jump
ssh -o ProxyJump=bastion user@target
Inline ProxyJump option
File transfer (scp & sftp)
7scp file user@host:/path/
Copy a local file to the server
scp user@host:/path/file .
Copy a remote file to the current dir
scp -r dir/ user@host:/path/
Recursively copy a directory
scp -P 2222 file user@host:/path/
Copy over a custom port (note capital -P)
sftp user@host
Start an interactive SFTP session
put localfile / get remotefile
Upload / download inside SFTP
rsync -avz -e ssh dir/ user@host:/path/
Efficient sync over SSH (resumable)
ssh-agent & forwarding
7eval "$(ssh-agent -s)"
Start the agent in the current shell
ssh-add ~/.ssh/id_ed25519
Add a key to the agent
ssh-add -l
List keys loaded in the agent
ssh-add -D
Remove all keys from the agent
ssh-add --apple-use-keychain ~/.ssh/id_ed25519
Store passphrase in macOS keychain
ssh -A user@host
Forward the agent for this connection
ForwardAgent yes
Config equivalent of agent forwarding
没有条目匹配“:q”。
关于 SSH 速查表
这份 SSH 速查表汇集了操作远程服务器所需的命令和配置:连接、密钥生成、安装公钥、~/.ssh/config 配置文件、端口转发与隧道、跳板机和堡垒机、用 scp 和 sftp 进行文件传输,以及 ssh-agent 与代理转发。
SSH 的语法很容易记个半懂——是用 -L 还是 -R 建立那条隧道?哪些 ssh-keygen 参数能生成现代密钥?ProxyJump 到底怎么用?这里的每一行都用确切的命令和一句话解释来回答其中一个问题。
本速查表免费,完全在浏览器中渲染。用搜索实时过滤,通过粘性目录跳转到指定章节,一键复制任意命令,并在 SSH 恰好出问题的关键时刻把它打印出来。
如何使用 SSH 速查表
- 打开速查表并浏览各章节,从「连接」「密钥生成」到「ssh-agent 与转发」。
- 搜索 tunnel、scp 或 ProxyJump 等关键词,即可实时过滤命令。
- 需要特定用法时,通过粘性侧边栏跳转到「端口转发/隧道」或「SSH 配置」章节。
- 点击命令或其复制图标进行复制,然后替换其中的主机和端口占位符。
- 打印速查表,以备服务器出现紧急状况时使用离线副本。
常见问题
共八个章节:连接、密钥生成、安装公钥、~/.ssh/config 配置文件、端口转发与隧道、跳板机和堡垒机、用 scp 和 sftp 传输文件,以及带转发功能的 ssh-agent。
有。隧道章节并排展示了 -L 和 -R 两种形式,并说明各自的转发方向,还包含动态转发——这是 SSH 中最容易混淆的部分之一。
有。其中有专门的章节讲解如何用 ssh-keygen 生成密钥,以及如何把公钥安装到服务器上,还有加载和转发密钥的代理命令。
可以。点击任意命令或该行的复制图标,即可把它复制到剪贴板,然后粘贴到终端并替换成你自己的主机。
是的,它是免费的,无需账户,而且打印出来也很整洁,方便离线使用。
热门搜索
ssh 速查表
ssh 命令列表
ssh keygen 命令
ssh config 文件示例
ssh 端口转发
ssh copy id
scp 和 sftp 命令
ssh 跳板机
需要帮助?
使用此工具时遇到问题?请告诉我们的团队。