Advertisement
bueddl

ssh opening

Jun 17th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. // Client
  2. int fd = connect(...);
  3. char buffer[100];
  4. read(fd, buffer, sizeof(buffer));
  5.  
  6. int major, minor;
  7. char impl[100];
  8. if (sscanf(buffer, "SSH-%d.%d-%99s", &major, &minor, impl) != 3 ||
  9.     !(major == MY_MAJOR_VERSION && minor == MY_MINOR_VERSION))
  10. {
  11.     write(fd, "Protocol mismatch.\n", 20);
  12.     close(fd);
  13.     abortTheShip();
  14. }
  15. // negotiate encryption settings
  16.  
  17. // Server
  18. int fd = accept(...);
  19. char buffer[100];
  20. read(fd, buffer, sizeof(buffer));
  21.  
  22. int major, minor;
  23. char impl[100];
  24. if (sscanf(buffer, "SSH-%d.%d-%99s", &major, &minor, impl) != 3 ||
  25.     !(major == MY_MAJOR_VERSION && minor == MY_MINOR_VERSION))
  26. {
  27.     write(fd, "Protocol mismatch.\n", 20);
  28.     close(fd);
  29.     abortTheShip();
  30. }
  31. // negotiate encryption settings
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement