Protocol 52 of 81Layer 7FrameAssembly v3.1.2
llms-full.txt
sshSecure Shell Transport Layer Protocol

Port 22 Version Banners & Key-Exchange Packets (admin <-> bastion ssh)

Default Port / Protocol
TCP 22
Host Endpoint Rule
Dual-Stack IPv4/IPv6
Wireshark Display Filter
ssh
Standards & Specs
RFC 4253
Wire Stack:Ethernet II[802.1Q / QinQ / MPLS]IPv4 / IPv6TCP 22SSH-2

What It Does on the Wire

Test SSH version-banner threat signatures (SSH-2.0-OpenSSH_9.6 vs legacy 1.99) and RFC 4253 binary kexinit -> newkeys framing over stateful TCP port 22.

Secure Shell (ssh, RFC 4253) provides encrypted CLI administration, SFTP file transfer, and port forwarding on TCP port 22. Before encryption starts, both sides exchange cleartext SSH-2.0-... identification banners followed by binary SSH_MSG_KEXINIT (msgcode 20) algorithm negotiation and SSH_MSG_NEWKEYS (msgcode 21) packets—which IDS engines (Suricata ssh.protoversion, ssh.software, Zeek HASSH) inspect to spot outdated SSH servers, lateral movement, or C2 tunnels.

FrameAssembly formats -terminated SSH version banners (banner), RFC 4253 binary padded kexinit frames (with 16-byte cookie and algorithm lists), newkeys transitions, and custom msgcode binary packets.

Test Vulnerable SSH Version & Lateral Movement IDS Rules

Replay specific banner "SSH-2.0-OpenSSH_7.4" or custom client banners (banner "SSH-2.0-Paramiko_2.12.0") across internal subnets to verify SOC alerts.

Bastion / Jump-Host Firewall ACL Verification (TCP 22 / 2222)

Test TCP 22 (or dstport 2222) reachability from admin subnets vs untrusted guest VLANs.

Zeek ssh.log & Key-Exchange Inspection Checks

Combine bidirectional banner, kexinit, and newkeys packets to populate complete Zeek SSH handshake logs.

Minimal Quickstart (ssh_quickstart.frasm)

Hit Preview Packets to compile in-browser and eyeball timestamps + wire byte lengths, or ship it straight to the Playground.

ssh_quickstart.frasm10 lines
Open in Playground
host jump_box { ip 10.10.99.5 }
host core_sw { ip 10.10.0.1 }
compile {
jump_box -> core_sw tcp syn srcport 51022 dstport 22 wait 1ms
jump_box <- core_sw tcp syn ack wait 1ms
jump_box -> core_sw tcp ack wait 1ms
jump_box -> core_sw ssh banner "SSH-2.0-OpenSSH_9.7" wait 1ms
jump_box <- core_sw ssh banner "SSH-2.0-Cisco-2.0"
}

What the Compiler Calculates So You Don't Have To

  • Defaults to TCP destination port 22 (psh ack) and appends standard RFC 4253 terminators to banner strings.
  • Computes RFC 4253 binary packet framing (4-byte packet_length, 1-byte padding_length, payload, and 8-byte block padding) automatically on kexinit, newkeys, and msgcode packets.
  • Populates valid curve25519 / chacha20-poly1305 / ssh-ed25519 name-lists inside kexinit so Wireshark dissects every KEX field cleanly.
Multi-Frame Lab · Ready to Compile

Complete SSH-2 Banner Exchange, KEXINIT Negotiation & NEWKEYS Cutover

Establishes a TCP 22 session between an admin workstation and a Linux server, exchanges version banners, negotiates keys via kexinit, activates encryption with newkeys, and sends encrypted session data.

ssh_handshake_audit.frasm16 lines
Open in Playground
host admin_ws { ip 172.16.99.10 }
host linux_srv { ip 172.16.10.22 }
compile {
admin_ws -> linux_srv tcp syn srcport 53220 dstport 22 win 65535 mss 1460 wait 1ms
admin_ws <- linux_srv tcp syn ack win 65535 mss 1460 wait 1ms
admin_ws -> linux_srv tcp ack wait 1ms
// 1. Cleartext RFC 4253 §4.2 protocol version exchange
admin_ws -> linux_srv ssh banner "SSH-2.0-OpenSSH_9.7p1" wait 1ms
admin_ws <- linux_srv ssh banner "SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13" wait 2ms
// 2. Binary KEXINIT (msgcode 20) + NEWKEYS (msgcode 21)
admin_ws -> linux_srv ssh kexinit cookie "0102030405060708" wait 1ms
admin_ws <- linux_srv ssh kexinit cookie "aabbccddeeff0011" wait 2ms
admin_ws -> linux_srv ssh newkeys wait 1ms
admin_ws <- linux_srv ssh newkeys
}
Terminal Commands (FrameAssembly CLI v3.1.2)
# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show ssh_handshake_audit.frasm

# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly ssh_handshake_audit.frasm ssh_handshake_audit.pcap
frameassembly ssh_handshake_audit.frasm ssh_handshake_audit.pcapng

# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse ssh_handshake_audit.pcap ssh_handshake_audit_edited.frasm

All ssh Keywords & Header Options

Every sub-keyword and header option is lowercase [a-z0-9]+ with zero underscores — mix and match them in any order after ssh:

src_host -> dst_host ssh [banner "<text>"] [kexinit] [newkeys] [msgcode <0..255>] [cookie "<text>"]
Keyword / OptionAccepted ValueDefaultEffect on Packet
banner "<text>"Quoted SSH identification string (e.g. "SSH-2.0-OpenSSH_9.7")"SSH-2.0-OpenSSH_9.6"Emits the cleartext -terminated SSH version banner.
kexinitKeyword flagOmittedEmits a binary RFC 4253 SSH_MSG_KEXINIT (20) packet with 16-byte cookie and KEX algorithm lists.
newkeysKeyword flagOmittedEmits a binary SSH_MSG_NEWKEYS (21) packet signaling transition to negotiated keys.
msgcode <0..255>RFC 4253 message number (e.g. 5 SERVICE_REQUEST, 50 USERAUTH_REQUEST)OmittedEmits a properly length-prefixed and block-padded SSH binary packet with the chosen message code.
cookie "<text>"Quoted cookie value for kexinit16 deterministic bytesPopulates the 16-byte KEX cookie inside kexinit messages.

Cross-Layer Wrappers Valid with ssh

802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol

11 options
OptionRange / FormatDefaultEffect on Packet
wait <number><ns|us|ms|s|m>Time gap (ns, us, ms, s, m)10msAdvances the packet timestamp clock after sending this packet and before the next packet (wait 0ns sends back-to-back).
payload "<text>" | hexpayload "<hex>"Quoted text or hex bytes (choose one)OmittedAppends or overrides raw payload bytes ("deadbeef" or "de:ad:be:ef") and updates packet lengths and checksums.
srcmac <mac> | dstmac <mac>Colon, hyphen, or Cisco dot MACHost MAC / RFC multicast MACOverrides the 14-byte Ethernet II source or destination MAC address for this single packet.
vlan <0..4095> [pcp <0..7>] [dei <0|1>]VLAN ID 0..4095, PCP 0..7, DEI 0..1UntaggedWraps the packet in an IEEE 802.1Q VLAN tag (0x8100) with optional 802.1p QoS priority.
qinq <0..4095> [innervlan <0..4095>]Outer S-VLAN 0..4095, Inner C-VLAN 0..4095Untagged (innervlan 1 when qinq is set)Double-tags the packet with outer IEEE 802.1ad S-Tag (0x88a8) plus inner IEEE 802.1Q C-Tag (0x8100).
mpls <0..1048575> [exp|tc <0..7>] [bos <0|1>] [mplsttl <0..255>]Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255Unlabeled (at most 1 mpls tag per packet)Inserts a 32-bit MPLS label header (0x8847) ahead of the Layer 3 header.
ttl <0..255> [dscp <0..63>] [ecn <0..3>]TTL/Hop Limit 0..255, DSCP 0..63, ECN 0..3ttl 64, dscp 0, ecn 0Sets IPv4 TTL or IPv6 Hop Limit plus DiffServ (DSCP) and ECN QoS markings.
ipid <0..65535> [df] [mf] [fragoffset <0..8191>]IPv4 ID, DF/MF flags, fragment offset 0..8191ipid 1, flags 0, fragoffset 0Sets IPv4 Identification, Do-Not-Fragment (df), More-Fragments (mf), and fragment offset (ignored over IPv6).
flowlabel <0..1048575>20-bit IPv6 Flow Label (0..1048575)0Sets the 20-bit IPv6 Flow Label for ECMP routing tests (ignored when running over IPv4 hosts).
srcport <0..65535> | dstport <0..65535>Port number 0..65535srcport 49152 (remembered), TCP 22Overrides source or destination port and remembers the port pair automatically on <- replies.
seq <number> | acknum <number> | win <0..65535> | syn | ack | psh | fin | rstTCP sequence/ack numbers, window size, flags & RFC 7323 optionspsh ack, win 65535, automatic TCP seq/acknumOverrides automatic TCP sequence tracking, flags, or RFC 7323 options (mss, wscale, sackperm, tsval, tsecr).

Gotchas & Quick Fixes

Start Custom Banners With SSH-2.0- so Wireshark Dissects Them as SSH

Avoid
jump_box -> core_sw ssh banner "OpenSSH_9.7"
Valid v3.1.2 Syntax
jump_box -> core_sw ssh banner "SSH-2.0-OpenSSH_9.7"

RFC 4253 requires SSH version strings to start with SSH-protoversion-softwareversion (SSH-2.0-...).

Send Banners Before kexinit on the Same 4-Tuple

Valid v3.1.2 Syntax
Exchange ssh banner lines before ssh kexinit

Stateful analyzers like Zeek and Suricata expect the cleartext SSH-2.0- banner exchange at the start of the TCP stream before binary kexinit frames.

Field Guide 03
Poke Stateful Firewalls, Suricata, Zeek & OT Conduits