Secure Shell (SSH): Transport Layer Protocol

A good source of information about the Secure Shell (SSH) is provided in RFC 4253. This network protocol provides a secure way to login to remote servers. This fundamental service provides a mechanism for other useful operations, such as secure file transfer.

The protocol will work over an underlying transport that protects transmission errors, such as TCP/IP (usually on port 22). The client always initiates the connection.

Once a raw socket connection has been established, both sides must send an identification string or banner, which has the following format:

SSH-<protocol version>-<software version> SP comments CR LF

The <protocol version> refers to the version of SSH, while the <software version> allows the receiver to determine the capabilities of the sender’s implementation. This string must be a maximum length of 255 characters, including all of the control characters. Key exchange must begin immediately following the banner.

Note: the server may send other lines before the banner, but each of these must not start with “SSH-” and must be terminated by a “CR LF”.

The Binary Packet Protocol should be expected after the banner, where each packet conforms to the following layout:

TypeSizeNameDescription
uint324packet_lengthlength of packet, excluding MAC and this field itself
byte1padding_lengthlength of padding bytes that follow the payload
bytepacket_length – padding_length -1payloadthe raw payload of the packet
bytepadding_lengthpaddingrandom padding bytes
bytemac_lengthMessage Authentication Code (MAC)Initially this must be "none"

Secure Shell (SSH): Transport Layer Protocol

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top