SSH Cheat Sheet
A searchable, printable SSH reference — connecting, keys, config, tunneling, SCP/SFTP and agent forwarding. Free.
Connecting
10ssh user@host
ssh -p 2222 user@host
ssh -i ~/.ssh/id_ed25519 user@host
ssh user@host 'uptime'
ssh -v user@host
ssh -t user@host 'sudo -i'
ssh -X user@host
ssh -o ServerAliveInterval=60 user@host
exit / Ctrl-D
~.
Key generation
8ssh-keygen -t ed25519 -C 'you@example.com'
ssh-keygen -t rsa -b 4096
ssh-keygen -t ed25519 -f ~/.ssh/work
ssh-keygen -p -f ~/.ssh/id_ed25519
ssh-keygen -y -f ~/.ssh/id_ed25519
ssh-keygen -l -f ~/.ssh/id_ed25519.pub
ssh-keygen -lv -f ~/.ssh/id_ed25519.pub
ssh-keygen -R host
Installing public keys
7ssh-copy-id user@host
ssh-copy-id -i ~/.ssh/work.pub user@host
ssh-copy-id -p 2222 user@host
cat ~/.ssh/id_ed25519.pub | ssh user@host 'cat >> ~/.ssh/authorized_keys'
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
pbcopy < ~/.ssh/id_ed25519.pub
SSH config (~/.ssh/config)
10Host myserver
HostName 203.0.113.10
User deploy
Port 2222
IdentityFile ~/.ssh/work
IdentitiesOnly yes
ForwardAgent yes
Host *.example.com
Host *
ServerAliveInterval 60
Port forwarding / tunneling
7ssh -L 8080:localhost:80 user@host
ssh -L 5432:db.internal:5432 user@host
ssh -R 9000:localhost:3000 user@host
ssh -D 1080 user@host
ssh -N -L 8080:localhost:80 user@host
ssh -f -N -L 8080:localhost:80 user@host
ssh -g -L 8080:localhost:80 user@host
Jump hosts / bastions
5ssh -J jump@bastion user@target
ssh -J h1,h2 user@target
ProxyJump bastion
ProxyCommand ssh -W %h:%p bastion
ssh -o ProxyJump=bastion user@target
File transfer (scp & sftp)
7scp file user@host:/path/
scp user@host:/path/file .
scp -r dir/ user@host:/path/
scp -P 2222 file user@host:/path/
sftp user@host
put localfile / get remotefile
rsync -avz -e ssh dir/ user@host:/path/
ssh-agent & forwarding
7eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
ssh-add -l
ssh-add -D
ssh-add --apple-use-keychain ~/.ssh/id_ed25519
ssh -A user@host
ForwardAgent yes
No entry matches “:q”.
About SSH Cheat Sheet
This SSH cheat sheet collects the commands and config you need to work with remote servers: connecting, key generation, installing public keys, the ~/.ssh/config file, port forwarding and tunneling, jump hosts and bastions, file transfer with scp and sftp, and ssh-agent with agent forwarding.
SSH syntax is easy to half-remember — is it -L or -R for that tunnel, which ssh-keygen flags produce a modern key, how does ProxyJump work? Each row here answers one of those questions with the exact command and a one-line explanation.
The sheet is free and rendered entirely in your browser. Filter it live with search, jump to a section from the sticky table of contents, copy any command with one click and print it for the moments when SSH is exactly what is broken.
How to use SSH Cheat Sheet
- Open the sheet and scan the sections, from Connecting and Key generation to ssh-agent & forwarding.
- Search for a term like tunnel, scp or ProxyJump to filter the commands live.
- Jump to Port forwarding / tunneling or SSH config via the sticky sidebar when you need a specific recipe.
- Click a command or its copy icon to copy it, then adapt the host and port placeholders.
- Print the sheet to keep an offline copy for server emergencies.