SSH knowledge, with examples

Command references and practical notes for connecting, managing keys and transferring files. Independent of the Secure Pipes user guide.

Unless stated otherwise, run examples on your local Mac or Linux computer in zsh or bash. alice and *.example.com are placeholders. Windows OpenSSH has different path, agent and tool availability conventions. Check ssh -V and man <command> for your installed version.

Connections and tunnels

ssh

Connect to a server, run commands and create encrypted tunnels.

Keys and authentication

ssh-keygen

Generate key pairs, inspect fingerprints and change a private key’s passphrase.

ssh-copy-id

Install your public key in a remote account’s authorized_keys.

ssh-agent

Keep signing identities available to SSH clients through an agent.

ssh-add

Add, inspect and remove identities in an existing agent.

ssh-keyscan

Collect server host keys for later inspection.

File transfer

scp

Copy files over an SSH connection.

sftp

Transfer files interactively over SSH.

Configuration

~/.ssh/config

Save repeatable connection options in the client configuration file.

sshd_config

Configure the OpenSSH server: listening, authentication, forwarding, access control and logging.

Server Security

Fail2ban

Install and configure Fail2ban to temporarily block repeated SSH authentication failures on an Ubuntu server.

SSH OTP

Add time-based one-time codes to SSH login using Linux PAM and Google Authenticator's PAM module.

SSH Hardening

Review and tighten SSH access on an Ubuntu server.

SSH Firewall

Review UFW rules and restrict SSH access to a known source.

SSH Key Safety

Create, deploy, verify and rotate SSH authentication keys.

SSH Recovery

Prepare a recovery path and troubleshoot SSH server configuration.

Appendix

Glossary

Explanations of SSH, authentication and networking terminology.