Skip to content

005: RFC 4253

Shane DeSeranno edited this page Oct 10, 2017 · 4 revisions

RFC 4253 is the primary document used to describe the core connection and key exchange mechanisms of SSH. I will be grabbing quotes from this document to help clarify parts that I found confusing.

The first sections we want to look at is 4.2. Protocol Version Exchange. This is states that once a client connects, both sides must send an identification string in the format of:

SSH-protoversion-softwareversion SP comments CR LF

In this case, protoversion should be 2.0, as that is the version being documented and used and the softwareversion can be any UTF-8 encoded string to identify the server, but it should not include a dash or space. Finally the SP means a space character and then comments can be an valid string. Finally the message must end in a carriage return and line feed, or CR/LF.

This means valid strings are:

SSH-2.0-billsSSH_3.6.3q3[CR][LF]
SSH-2.0-MySSHServer_1.0 Some Comment Allowed here[CR][LF]

So, our first task in our server is send our Protocol Version Exchange message to the client, and also read the Protocol Version Exchange from the client's socket.

I have read the full RFC, and I know that most of the SSH data is sent as raw byte data and will require special processing, but until we should read from the socket for the first [CR][LF] and save this value off. Once we have received that, we'll then need to start reading the socket as a binary data stream.

Let's continue add Reading Protocol Version Exchange