Strovent SystemsSign in
Reference

SSH concepts

Key types, known hosts, certificates, agents, jump hosts and port forwarding.

SSH: how it worksThe layers of an SSH connection, what happens when you connect, and the words you will see.Key types and formatsEd25519, ECDSA and RSA keys, security keys, and the file formats you might be handed.Convert a PuTTY .ppk key to OpenSSH format, and PPK version 3How to export a PuTTY .ppk key as an OpenSSH key with PuTTYgen, which export option gives the newer format, and what PPK version 3 means for older tools.Known hosts and fingerprintsHow SSH checks the host, what the first-connection prompt and the known_hosts file mean, and what to do if the key changes.SSH host certificates and @cert-authority in known_hostsHow a @cert-authority line in known_hosts lets SSH trust every host certificate signed by one CA, how to sign a host key, and why a client still prompts.OpenSSH certificatesHow a certificate authority signs SSH keys, what a user certificate contains, and how to make one.The agent and agent forwardingWhat an SSH agent does, how forwarding works, and why it carries a risk.Jump hosts (ProxyJump)How a bastion or jump host works, why it is safe, and the syntax for one or several hops.Port forwarding: local, remote, dynamicLocal, remote and dynamic forwarding: what each does, the syntax, and the limits.Authorized keys and permissionsWhere the host stores your public key, the file permissions it insists on, and why a key login can fail.Security keys (FIDO2) with SSHHow a hardware security key is used for SSH, the key types, and what touch and PIN mean.The ssh config fileThe options in a client config file that save typing: host names, users, keys, jump hosts and keep-alives.SSH keep-alives and idle timeoutsWhat ServerAliveInterval, ClientAliveInterval and TCPKeepAlive do, which side each one belongs on, and why an SSH session can still drop.SSH to a Mac from a phone or tablet, Remote Login and sleepTo SSH into a Mac, turn on Remote Login in Sharing settings and keep the Mac awake. A sleeping Mac or a closed laptop lid stops answering SSH connections.Telnet to port 22: what the SSH-2.0 banner meansTelnet or nc to port 22 shows a line like SSH-2.0-OpenSSH_9.6. That proves an SSH server is reachable, but Telnet cannot log in to it. How to read the result.ssh-copy-id through a jump host (ProxyJump)ssh-copy-id has no -J flag, but it passes -o to ssh. Run ssh-copy-id -o ProxyJump=jump.example.com [email protected], or set ProxyJump in ~/.ssh/config.Hashed known_hosts: find, remove or hash hosts with ssh-keygenHashed known_hosts entries hide the host name and cannot be decoded. Use ssh-keygen -F host to find one, -R host to delete it, and -H to hash an existing file.Rotate an SSH host key without warnings: UpdateHostKeysAdd the new host key next to the old one, let OpenSSH clients learn it through UpdateHostKeys, then remove the old key. Clients that learned it see no warning.SSH port forwarding through a jump host: -J with -LCombine -J and -L: ssh -N -J [email protected] -L 5433:db.internal:5432 [email protected]. The last host in the chain connects to the destination.Use a different SSH key for the jump host and the targetssh -i applies only to the target, not to a -J jump host. Give each host its own Host block with IdentityFile, or pass the jump key in a ProxyCommand.Change or remove an SSH key passphrase with ssh-keygen -pRun ssh-keygen -p -f with the key file, type the old passphrase, then a new one, or press Enter twice to remove it. The public key stays the same.SSH ControlMaster: reuse one connection with ControlPath and ControlPersistControlMaster lets later ssh, scp and sftp commands reuse one open SSH connection, with no new login. Set ControlMaster, ControlPath and ControlPersist.Kill a frozen SSH session with Enter ~. (OpenSSH escape sequences)Press Enter, then ~ then . to close a hung OpenSSH session at once. Use ~~. for the inner ssh in a nested login, ~? for the list, and EscapeChar to change ~.Keep an SSH tunnel running: autossh, ServerAliveInterval and systemdA tunnel stays up when ssh exits as soon as the link dies and something restarts it. Use ServerAliveInterval, ExitOnForwardFailure, and autossh or systemd.Check which CA signed an SSH certificate, and revoke a certificate with a KRLRead an OpenSSH user certificate with ssh-keygen -L, compare its Signing CA with the CA key the server trusts, and revoke a certificate by serial or key ID.Use an ed25519-sk security key with ssh-agent: ssh-add, providers and macOSHow ssh-add loads an ed25519-sk or ecdsa-sk key into ssh-agent, what SSH_SK_PROVIDER and ssh-agent -P change, and two OpenSSH installs on one Mac.SSH with a FIDO security key never asks me to touch the keyWhen ssh shows "Confirm user presence for key", when the prompt goes through ssh-askpass instead, and how no-touch-required keys skip the touch altogether.sshd_config.d drop-in ignored: the first value wins (KexAlgorithms and others)A setting in /etc/ssh/sshd_config.d/99-something.conf seems to be ignored. sshd uses the first value it reads for most keywords, so an earlier file wins.bind_address in ssh -L and ssh -R: localhost, * and GatewayPortsThe optional first field of ssh -L and -R picks the address a forwarded port listens on. What localhost, * and an IP mean, and how GatewayPorts decides.ssh -R with port 0: let the server pick the port, and find out which onessh -R 0:host:port asks the server for any free port. ssh prints "Allocated port N for remote forward", and with -O forward the number alone, for scripts.Turn off the SSH login message: motd, "Last login" and the pre-login bannerThe text after an SSH login comes from the motd, PAM and Last login; the text before the password is the Banner. Hide yours with ~/.hushlogin or change sshd.SSH "Warning: Permanently added ... to the list of known hosts": what it meansssh prints this when it saves a new host key to known_hosts. Seeing it on every connection means the key is not being saved. How to fix that or hide it.

Other categories