作为一个小型(大型)业余爱好项目,我已着手在C#中创建一个(非常原始的)ssh-2.0客户端.这是为了探索和更好地理解DH,并帮助我的加密熟悉:)
根据RFC 4253,我已经开始了这样的初始连接:
(省略不相关的变量预设等)
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 …Run Code Online (Sandbox Code Playgroud)