The three layers

  1. Transport layer (RFC 4253). Algorithm negotiation, server authentication, key exchange, encryption, and integrity. Produces a secure channel.
  2. User authentication layer (RFC 4252). Public key, password, host-based, or keyboard-interactive authentication of the user to the server.
  3. Connection layer (RFC 4254). Multiplexes multiple logical channels onto the single secure connection: interactive sessions, port forwards, X11, agent forwarding, SFTP subsystems.

What's negotiated

Host key trust

The server presents a host key during the handshake. The client compares it against ~/.ssh/known_hosts; on first connection, the user accepts or rejects the fingerprint. This is Trust On First Use (TOFU). For higher assurance, an organisation can use SSH certificates signed by a CA, which lets clients trust any server presenting a valid signed certificate without per-host pinning.

i

SFTP and SCP run over SSH. SFTP (SSH File Transfer Protocol) is a subsystem of the SSH connection layer — not a variant of FTP. SCP uses SSH to run a remote scp binary.

Useful client tricks