SSH

SSH

innocentzero

2026-06-14

#networks #protocol | Status: Complete

The protocol that I use on almost a daily basis...

SSH

The protocol is broadly structured as follows:

| User Auth | Conn |
| Transport Layer  |
|       TCP        |
|        IP        |

Transport layer protocol

Each server has a public-private key pair. ssh-keygen for openSSH. The keys are used for verifying the authenticity of the server during key exchange.

There are two alternative trust models:

The packet structure is as follows:

seq | [packet-len | pad-len | compressed-payload | padding ] | MAC

The contents in square brackets are encrypted. Everything is MAC'd.

Auth modes

Connection Protocol

Channels

Local Port forwarding

Remote/Reverse port forwarding

Dynamic port forwarding

These work on the basis of forwarding traffic from the port that's not blocked by the firewall. The thing that's dynamic is the port on the remote machine. It sets up a SOCKS proxy server and then forwards all connection requests to the SSH server via the secure SSH tunnel. The SSH server then sends the requests to the final destination.

SOCKS is needed here as applications negotiate the final destination address and port using SOCKS which the server later forwards the request to.