SSH cheat sheet
Connect through a bastion, forward a database port to your laptop, copy files both ways, and set up keys properly, without rereading the man page.
In Snippet Keeper, click Import at the bottom of the sidebar and choose the file. They land in your ssh app, and ones you already have are skipped. The highlighted parts become fill-in fields: type a value (or pick one), and the finished command is on your clipboard.
Connecting
ssh user@host
ssh -p port user@host
ssh -i key user@host
ssh user@host 'command'
ssh -J jump_user@jump_host user@host
ssh -T git@github.com
~.
Keys
ssh-keygen -t ed25519 -C "email"
ssh-copy-id user@host
ssh-add --apple-use-keychain key
ssh-add -l
pbcopy < key
ssh-keygen -lf key
ssh-keygen -R host
Tunnels
ssh -N -L local_port:target_host:target_port user@host
ssh -N -R remote_port:localhost:local_port user@host
ssh -N -D port user@host
Copying files
scp file user@host:path
scp user@host:path dest
scp -r dir user@host:path
rsync -avz --progress source user@host:dest
rsync -avzn --delete source user@host:dest
Config
Host alias
HostName host
User user
IdentityFile ~/.ssh/id_ed25519
Host alias
HostName host
User user
ProxyJump jump_host
Host *
ServerAliveInterval 60
Keep these one keystroke away.
Snippet Keeper is a Mac app for the commands you keep looking up. Press ⌥⇧Space in any app, type a few letters, fill in the blanks, and it’s on your clipboard.