SSH replaced Telnet, rlogin and rsh, which sent data and passwords in plain text. The protocol was created by Tatu Ylönen, who described it in a paper at the USENIX Security conference in 1996; today it is an IETF standard, RFC 4251–4254, and the most widely used implementation is OpenSSH.
How the protocol works
The client builds the connection: it finds the server by name or address and opens a TCP connection to port 22. The two sides then agree on a cipher, exchange keys and verify each other, and only then is a channel opened for work. The standard describes SSH as three layers, each running on top of the previous one.
| Layer | What it does |
|---|---|
| Transport | authenticates the server, encrypts the data and protects it from tampering; encryption keys are generated afresh for every connection |
| Authentication | authenticates the client, most often with a public key or a password; a key can also replace a password in automation |
| Connection | splits the encrypted tunnel into several independent channels: shell, port forwarding, files |
Every server has a host key: the client checks it to make sure it is talking to the right server and not an eavesdropper. On the first connection the client shows the key fingerprint and remembers it; if the key changes, it warns you. This scheme is called trust on first use: verify the fingerprint over a trusted channel rather than accepting it blindly.
Keys instead of passwords
The standard way to log in to a server is a key pair: the public key goes into the ~/.ssh/authorized_keys file on the server, and the private key stays with the user. This login resists password guessing and lets automation work without a human.
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519ssh-copy-id -i ~/.ssh/id_ed25519.pub admin@203.0.113.10ssh -i ~/.ssh/id_ed25519 admin@203.0.113.10What else SSH can do
- running a command without an interactive shell, which is what Ansible and deployment over Git are built on
- copying files with the
scpandsftputilities; the SFTP subsystem runs on top of SSH - port forwarding: local and remote tunnels, a gateway for a SOCKS proxy
- the
ssh-agentagent keeps decrypted keys in memory so you do not have to enter the key passphrase every time
Sources
the term is written from these pages- RFC 4251 — The Secure Shell (SSH) Protocol Architecturerfc-editor.org/rfc/rfc4251(opens in a new tab)
- Т. Юлёнен. SSH — Secure Login Connections over the Internet (USENIX Security, 1996)usenix.org/legacy/publications/library/proceedings/sec96/full_papers/ylonen/(opens in a new tab)
- OpenSSHopenssh.com(opens in a new tab)
Verified 9 Nov