Security and remote accessApplicationRFC 4253
SSH: a secure remote login
How you safely control a server from far away: agree on encryption, check who the server is, then log in.
Ports and use: TCP 22
In one sentenceSSH sets up an encrypted tunnel first, then proves who you are inside it.
Think of it like thisIt is meeting someone in a soundproof room: you check they are the right person at the door, then talk privately.
Watch it happen
8 steps and 3 byte-by-byte decodes. Use the buttons or the arrow keys. Hover or focus a field to find its bytes.
- Your terminal
- Server
- Server bannerServer to Your terminal
- Client bannerYour terminal to Server
- KEXINIT: what we supportYour terminal to Server
- Key exchange: client shareYour terminal to Server
- Key exchange: server replyServer to Your terminal
- NEWKEYSYour terminal to Server
- AuthenticationYour terminal to Server
- Session opensServer to Your terminal
Step 1 of 8 Server banner
Server → Your terminal
As soon as the TCP connection opens, the server sends its version as one line of text.
Server version line 21 bytes
SSH-2.0-OpenSSH_9.6↵
| Field | Text | What it means |
|---|---|---|
| Version string | SSH-2.0-OpenSSH_9.6↵ | SSH, protocol version 2.0, and the software name and version. |
Step 2 of 8 Client banner
Your terminal → Server
The client answers with its own version line.
Client version line 28 bytes
SSH-2.0-PuTTY_Release_0.80↵
| Field | Text | What it means |
|---|---|---|
| Version string | SSH-2.0-PuTTY_Release_0.80↵ | The same format. After this, all messages are binary. |
Step 3 of 8 KEXINIT: what we support
Your terminal → Server
Both sides send lists of algorithms in order of preference. The first one that is on both lists is used. Shown here as text for clarity; on the wire each list has a length in front.
Algorithm lists (simplified) 111 bytes
curve25519-sha256ssh-ed25519[email protected],[email protected]implicit with the ciphers above
| Field | Text | What it means |
|---|---|---|
| Key exchange | curve25519-sha256 | How the shared secret will be created. |
| Host key type | ssh-ed25519 | The type of key the server proves its identity with. |
| Encryption | [email protected],[email protected] | How the traffic will be encrypted. Two options, in order of preference. |
| Integrity | implicit with the ciphers above | These ciphers also detect tampering. |
Step 4 of 8 Key exchange: client share
Your terminal → Server
The client creates a temporary key pair and sends the public half.
Step 5 of 8 Key exchange: server reply
Server → Your terminal
The server sends its host key, its own temporary public key and a signature. The client checks the host key against its known_hosts file. If it is new you are asked to confirm the fingerprint.
Step 6 of 8 NEWKEYS
Your terminal → Server
Both sides announce they are switching to the new keys. Everything after this is encrypted.
Step 7 of 8 Authentication
Your terminal → Server
Inside the tunnel, the client proves who you are with a password or by signing a challenge with your private key. A key never leaves your computer.
Step 8 of 8 Session opens
Server → Your terminal
The server accepts and opens a channel. Your typed commands and the results now flow through the encrypted tunnel.
Where you meet it
- Managing Linux servers and cloud machines from a terminal.
- Pushing code to GitHub or GitLab over SSH.
- Tunnelling other traffic safely, for example to a private database.
Common mistakes
- Clicking "yes" to a new host key without checking the fingerprint when it matters.
- Using passwords on internet-facing servers instead of keys, which invites guessing attacks.
- Leaving a private key without a passphrase on a shared laptop.
- Copying a private key into a repository or chat. Share only the public key.
Try it yourself
Run these on your own computer and compare the output with the lesson above.
ssh -v [email protected]Verbose mode prints each step: banner, algorithm choice, host key check and authentication.ssh-keygen -t ed25519 -C "[email protected]"Creates a key pair. Share only the .pub file.ssh-keyscan -t ed25519 github.comShows a server's public host key.
Addresses and values in the examples are made up for teaching (the 203.0.113.x range is reserved for documentation). Real traffic carries more options and details. Check the standard named above for the full rules.