SSH (OpenSSH) 10 cheatsheet

SSH (OpenSSH) 10: Keys and agent

9 common SSH (OpenSSH) 10 tasks.

Create a key pair

Generate an Ed25519 key. Set a passphrase when asked.

ssh-keygen -t ed25519 -C "[email protected]"

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.

ssh-copy-id [email protected]

Print your public key

Show the public key to paste into GitHub or a server.

cat ~/.ssh/id_ed25519.pub

Start the agent

Start ssh-agent in the current shell.

eval "$(ssh-agent -s)"

Add a key to the agent

Load a key so you enter its passphrase once. On macOS, add --apple-use-keychain to remember it.

ssh-add ~/.ssh/id_ed25519

List loaded keys

Show the keys in the agent.

ssh-add -l

Show a key's fingerprint

Print the fingerprint of a key, to compare with what a service displays.

ssh-keygen -lf ~/.ssh/id_ed25519.pub

Remove an old host key

Remove a host from known_hosts after its key legitimately changed, such as after reinstalling.

ssh-keygen -R example.com

Caution: A changed host key can also mean someone is intercepting your connection. Make sure the change is expected.

Fix permissions that SSH rejects

SSH ignores keys and config files that other users can read.

chmod 700 ~/.ssh && chmod 600 ~/.ssh/id_ed25519 ~/.ssh/config

Was this page helpful?