title: Get SSH Banner using raw sockets
body: <p>I recently wrote a small script to get a list op ssh servers in my local network because I didn't know the ip address of my computers without connecting them to a screen and looking it up (which would eliminate the need for ssh). Because I have multiple ssh servers, I want to know which ip address belongs to a computer. To do that, I thougth of using the ssh banner to indentify a computer. Since using a ssh library would be a little bit overkill to just get the banner and for the learning experience, I want to implement this using sockets.</p>
  
  <p>Atm I have this in python:</p>
  
  <pre><code>from socket import socket
  s = socket()
  s.connect((ip,22))
  s.send(s.recv(100)) # send the ssh version back
  </code></pre>
  
  <p>Until here it works, and reading from the socket gives a list of supported encryption algoritms. I should send a list back of algoritms and my mac address (in which i haven't succeeded yet). I tried sending the list I got from the server, but after that I didn't got any response.</p>
  
  <p>According to the documentation, the server could at any moment send the banner. When I use a normal ssh client, it displays the banner before I log in, so I don't think I need to go through the whole authenticating process.</p>
  
  <p>Whats the most simple way to get the ssh banner using sockets?</p>
  
  <p>(Code doesn't have to be in python)</p>