Tool cheatsheet
SSH (OpenSSH) 10 Cheatsheet
Connect to servers, manage keys, write ~/.ssh/config, forward ports, jump through bastion hosts and harden sshd.
Connecting
- Connect to a server — Open a shell on a remote host.
- Connect on another port with a specific key — Use a non-default port and an identity file.
- Run a command on the server — Run one command and print its output locally.
- Run an interactive program remotely — Allocate a terminal so programs like top and sudo work.
- Debug a failing connection — Print detailed logs of the connection and authentication attempts. Add more v's for more detail.
- Connect through a bastion host — Reach a private server by hopping through a jump host.
- Copy a file over SSH — Copy a local file to a server.
- Copy with resumable transfers — Use rsync over SSH to resume interrupted transfers.
Keys and agent
- Create a key pair — Generate an Ed25519 key. Set a passphrase when asked.
- Install your public key on a server — Add your public key to the server's authorized_keys so you can log in without a password.
- Print your public key — Show the public key to paste into GitHub or a server.
- Start the agent — Start ssh-agent in the current shell.
- Add a key to the agent — Load a key so you enter its passphrase once. On macOS, add --apple-use-keychain to remember it.
- List loaded keys — Show the keys in the agent.
- Show a key's fingerprint — Print the fingerprint of a key, to compare with what a service displays.
- Remove an old host key — Remove a host from known_hosts after its key legitimately changed, such as after reinstalling.
- Fix permissions that SSH rejects — SSH ignores keys and config files that other users can read.
~/.ssh/config
- Define a host alias — Connect with ssh web instead of the long form.
- Configure a jump host — Always reach a private server through the bastion.
- Keep idle connections alive — Send a keepalive every minute so idle sessions don't drop.
- Reuse connections for speed — Share one connection between sessions, which makes repeated ssh and scp commands fast.
- Use a specific key for GitHub — Use a dedicated key for one service.
Port forwarding
- Reach a remote service locally — Make a remote database available at localhost:5433, through the server.
- Expose a local service on the server — Make your local web server available on the server's port 8080.
- Create a SOCKS proxy — Run a SOCKS5 proxy on localhost:1080 that sends traffic through the server.
- Run a tunnel in the background — Forward a port without opening a shell. -N means no command, -f means go to the background.
- Stop a background tunnel — Find and end the tunnel process.
Server (sshd)
- Test the server configuration — Check /etc/ssh/sshd_config for errors before restarting. A mistake can lock you out.
- Disable password logins — Allow keys only and block root logins. Confirm key login works first, in a second session.
- Apply sshd changes — Reload the SSH server after editing its configuration. Existing sessions stay open.
- See login attempts — Follow SSH logins and failures on systemd systems.
- Limit who can log in — Allow only listed users to connect.
- Change the SSH port — Move sshd to another port. Open the new port in the firewall before restarting.
Related cheatsheets
- Ansible 2 cheatsheet — Run ad-hoc commands and playbooks, manage inventories, roles, collections and secrets with Ansible.
- Argo CD 3 cheatsheet — Install Argo CD, define Applications declaratively, and manage sync, diffs, history and rollbacks with the argocd CLI.
- AWS CLI 2 cheatsheet — Configure credentials and manage S3, EC2, Lambda, logs, containers and secrets with the AWS CLI v2.
- Azure CLI 2 cheatsheet — Sign in and manage resource groups, VMs, web apps, storage, Kubernetes, registries and secrets with the az command.
- Bash and Linux 5 cheatsheet — Everyday shell and Linux commands for files, searching text, permissions, processes and servers.
- Claude API cheatsheet — Call Claude from Python, TypeScript or curl: messages, streaming, thinking, tools, structured output, caching, batches and error handling.