Primitive ssh connection (lowlevel)

as a small (large) hobby project that I decided to make an (very primitive) ssh-2.0 client in C #. This should learn and better understand DH and help develop my knowledge of encryption :)

According to RFC 4253, I started the initial connection as follows:

(excluding inappropriate presetting of vars, etc.)

Random cookie_gen = new Random(); while ((ssh_response = unsecure_reader.ReadLine()) != null) { MessageBox.Show(ssh_response); if (ssh_response.StartsWith("SSH-2.0-") { // you told me your name, now I'll tell you mine ssh_writer.Write("SSH-2.0-MYSSHCLIENT\r\n"); ssh_writer.Flush(); // now I should write up my supported (which I'll keep to the required as per rfc 4253) ssh_writer.Write(0x20); // SSH_MSG_KEXINIT byte[] cookie = new byte[16]; for (int i = 0; i < 16; i++) cookie[i] = Convert.ToByte(cookie_gen.Next(0, 10)); ssh_writer.Write(cookie); // cookie // and now for the name-list // This is where I'm troubled // "Footer" ssh_writer.Write(0x00); // first_kex_packet_follows ssh_writer.Write(0x00); // 0 ssh_writer.Flush(); } } 

As you can see on page 16 of RFC 4253, I have to give 10 lists of names. Are they just intended for the lines, or how can I mark the beginning / end of each list (just using a new line \ n)? Am I even on the right track here? (keep in mind that I will process DH and encrypt past this point. My question is based solely on the initial contact so far).

Any help or comments are welcome and appreciated,

PS: I know that libraries exist, but this does not apply to my project.

+6
c # ssh low-level
source share
1 answer

Well, as RFC 4251 states on page 9:

Null-termination MUST NOT be used, either for individual names or for the list as a whole.

There are also examples in the named RFC.

+2
source share

All Articles