wire / wire-format / ssh-binary-packet

SSH binary packet protocol

An SSH (RFC 4253) binary packet: 4-byte packet length (big-endian, not including the length field itself or MAC), 1 byte padding length, payload (max 32768 bytes, typically 35000 with extensions), random padding (4-255 bytes, total packet length multiple of cipher block size or 8), then an optional MAC (if not using AEAD).

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: SSH binary packet protocol

wire format

spec: RFC 4253 (SSH Transport Layer)

An SSH (RFC 4253) binary packet: 4-byte packet length (big-endian, not including the length field itself or MAC), 1 byte padding length, payload (max 32768 bytes, typically 35000 with extensions), random padding (4-255 bytes, total packet length multiple of cipher block size or 8), then an optional MAC (if not using AEAD).

fieldsizemeaning
Packet length4 bytesLength of (padding length + payload + padding) in bytes, big-endian. Does not include itself or the MAC.
Padding length1 byteNumber of padding bytes (4-255, or 0 with AEAD ciphers).
PayloadvariableThe SSH message (key exchange, service request, user auth, channel data, ...).
Random padding= padding lengthRandom bytes to fill to a block boundary; also hides message length.
MACvariableMessage authentication code (HMAC-SHA1/SHA2) over sequence number + unencrypted packet; omitted with AEAD (chacha20-poly1305, aes-gcm).

example:

00 00 00 0c 05 0a 01 00 00 00 04 74 65 73 74 00 00 00 00

Packet length 12, padding 5, payload = SSH_MSG_KEXINIT-ish (shortened)


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/ssh-binary-packet or /wire-format/ssh-binary-packet.json