{"canonical_url":"https://engineer.company/glossary/ssh/","content_markdown":"# SSH\n\n## What it is\n\nSSH, short for Secure Shell, is a network protocol for signing in to another computer and running\ncommands on it across a network nobody trusts, with the traffic encrypted and both ends proving who\nthey are first. The name covers three things: the protocol, published by the IETF in January 2006 as\na set of RFCs led by RFC 4251; OpenSSH, the implementation maintained by the OpenBSD project and the\none this article's examples use; and the `ssh` command, which talks to a server daemon called\n`sshd`.\n\nRFC 4251 describes three layers over one connection, normally TCP port 22, the number IANA assigned\nto it. The transport layer runs the key exchange, proves the server's identity with its host key,\nand then encrypts and integrity-checks everything that crosses. The user authentication layer runs\ninside that tunnel and settles who the client is: by public key, which every implementation must\nsupport, by password, which is optional, or by host-based trust. The connection layer divides the\ntunnel into channels, so one login can carry an interactive shell, a single command, an SFTP file\ntransfer and several forwarded ports at once.\n\nSSH replaced telnet and rlogin, which sent sessions and passwords across the network as plain text.\nThe protocol in use today is version 2.\n\n## Why it matters\n\nOn a server, SSH is the front door. A machine in a data centre or a cloud rarely has a keyboard\nwithin anyone's reach, so administration, deployments, file copies and automated configuration all\narrive through SSH, and whoever logs in with enough privilege owns the machine.\n\nPublic key authentication is what lets SSH be convenient and strong at once. The user keeps a\nprivate key on their own machine and puts the matching public key on the server, by default in\n`~/.ssh/authorized_keys`. At login the client signs data tied to that session, so the key itself\nnever crosses the wire. A stolen password can be replayed from anywhere, and a server that accepts\npasswords can be guessed at by anyone who reaches its port; automated tools do exactly that. OpenSSH\naccepts passwords out of the box, so turning them off is a decision each server has to make.\n\nTrust also runs the other way, because the client needs to know it reached the right server. Each\nserver holds a host key, and RFC 4251 offers two ways to trust it: a local list on the client that\nmaps each host name to its key, or a certification authority that signs host keys so the client\nholds only the authority's key. Most people use the first in its loosest form, which the RFC accepts\nas a concession to usability: take the key unchecked on first contact, save it in\n`~/.ssh/known_hosts`, and compare against it on every later connection. This is usually called trust\non first use. The first login is only as safe as the network it crosses, which is why OpenSSH asks\nbefore saving a new key and refuses outright when a known host presents a different one.\n\nSSH is also a transport that other tools build on. Git pushes and pulls over it, `scp` and `sftp`\ncopy files with it, Ansible reaches its hosts through it, and port forwarding lets a laptop reach a\ndatabase that listens only on a server's loopback interface without opening it to the internet.\n\n## What it looks like in practice\n\nThe company's own host accepts interactive logins over SSH and nothing else, and its\n[hardening is checked in three stages](/portfolio/hardened-ssh-to-24-validated-directives/)\neach time the automation role that owns the configuration runs. The checks date from September 2026,\nwhen an access report compared the settings the daemon had resolved with the ones the role wrote,\nand two differed: the distribution's defaults were live lines read before the role's drop-in, and\nsshd kept the earlier value. Renaming the drop-in so it sorts before the vendor's file closed the\ngap. Now an SSH configuration has to pass three gates: the candidate parses as valid syntax before\nit is put in place, the assembled set of files passes a check after installation, and the daemon's\nresolved settings are compared with 24 expected directives, so\na value that loses to an earlier line stops the run. Two directives are left out deliberately: the\ncurrent daemon has dropped both.\n\nA month earlier, a review in August 2026\n[found three brute-force protections that had never worked](/portfolio/three-locks-on-the-door-none-of-them-locked/)\nsince the host was built. The ban jail was watching port 22 while the daemon listened on 1986. The\nfirewall's rate limit came after a broader rule that allowed the same traffic, and since the first\nmatching rule wins, the limit never saw a packet, though the status output kept listing it. The ban\naction relied on a packet-filter tool that the package manager only recommends, so the jail spotted\nattackers and then errored each time it tried to block one. The review left two standing rules:\nevery security control is backed by a check that proves it acts, and a firewall rule is confirmed by\nits position as well as its presence.\n\nThe [company's own git forge](/portfolio/your-code-on-your-own-hardware/) uses SSH as a\ntransport rather than a way to log in. It was picked because it is driven over SSH and has no web\nadmin panel to defend. Nobody gets in anonymously or without a key, and every repository is private.\nIts SSH listener accepts connections on loopback only, at port 23231, and people outside reach it by\nhopping through a jump host, so the firewall opens no extra port for it.\n\n## Where it goes wrong\n\n**A hardening line sits in the file and the server ignores it.** For most keywords `sshd` keeps the\nfirst value it reads, and an `Include` expands its files in lexical order, so when the main file\npulls in a directory of drop-ins first, a vendor file that sorts early beats yours and both files\nstill look right. Searching the configuration proves only that a line was written. Ask the daemon\ninstead: `sshd -t` checks the syntax, and `sshd -T` prints the settings it will actually use.\n\n```text\n/etc/ssh/sshd_config.d/10-vendor.conf:     PasswordAuthentication yes\n/etc/ssh/sshd_config.d/50-hardening.conf:  PasswordAuthentication no\n\n$ sudo sshd -T | grep -i '^passwordauthentication'\npasswordauthentication yes\n```\n\n**A changed host key gets deleted and accepted.** When a known server presents a different host key,\n`ssh` prints a warning and refuses to connect. The reflex is `ssh-keygen -R` on the host name, a\nreconnect and a typed yes, which is everything a man-in-the-middle needs. Confirm the new\nfingerprint through another channel first, for example with `ssh-keygen -lf` on the server's public\nhost key from its console. In scripts, `StrictHostKeyChecking no` is worse than it looks: besides\nsaving new keys silently, it lets connections to hosts whose keys have changed proceed, within some\nlimits. The `accept-new` setting saves unknown hosts and still refuses changed keys.\n\n**Password logins stay open to the whole internet.** `PasswordAuthentication` defaults to yes, and\nso does keyboard-interactive authentication, which can ask for the same password by another route.\nOnce every user has a key, set both to no. `PermitRootLogin` already defaults to\n`prohibit-password`, which refuses passwords for root but still lets a root key in. Moving the\ndaemon off port 22 changes where it listens, not who can guess at it, and every control that names\nthe port has to move with it, as the ban jail above shows.\n\n**Agent forwarding lends your keys to the server.** With `ForwardAgent` on, or `ssh -A`, anyone who\ncan bypass file permissions on the remote host, root included, can use your agent to authenticate\nelsewhere as you while you stay connected. They cannot copy the key, but they can sign with it. To\nreach a machine behind a bastion, use a jump host instead: `ssh -J bastion.example.com app.internal`\nforwards a TCP connection through the bastion and negotiates the session with the target end to end,\nso the bastion relays bytes it cannot read and the key stays on your laptop.\n\n## Further reading\n\n- [RFC 4251: The Secure Shell (SSH) Protocol Architecture](https://www.rfc-editor.org/rfc/rfc4251) —\n  the three layers, the two host key trust models and the security considerations.\n- [RFC 4253: The Secure Shell (SSH) Transport Layer Protocol](https://www.rfc-editor.org/rfc/rfc4253)\n  — key exchange, host key verification and the version string each side sends first.\n- [RFC 4252: The Secure Shell (SSH) Authentication Protocol](https://www.rfc-editor.org/rfc/rfc4252)\n  — how public key, password and host-based logins work on the wire.\n- [sshd_config(5)](https://man.openbsd.org/sshd_config) — every server keyword with its default, and\n  the rule that the first value obtained is used.\n- [ssh_config(5)](https://man.openbsd.org/ssh_config) — the client side, including\n  StrictHostKeyChecking, ProxyJump and ForwardAgent.\n- [sshd(8)](https://man.openbsd.org/sshd) — the `-t` and `-T` test modes and the authorized_keys and\n  known_hosts formats.\n\n\u003chttps://engineer.company/glossary/ssh/\u003e\n","date_modified":"2026-10-20T21:59:50Z","description":"How SSH logs you in to a remote server, why keys beat passwords and host keys matter, and the config traps that leave hardening written down but switched off.","formats":{"gemtext":"https://engineer.company/glossary/ssh/index.gmi","gopher":"https://engineer.company/glossary/ssh/gophermap","html":"https://engineer.company/glossary/ssh/","json":"https://engineer.company/glossary/ssh/index.json","markdown":"https://engineer.company/glossary/ssh/index.md","pdf":"https://engineer.company/glossary/ssh/index.pdf"},"kind":"page","language":"en","title":"What is SSH?","url":"https://engineer.company/glossary/ssh/","version":1}