title: Identifying services listening on remote ports
body: <p>I'd like to elaborate a little bit on <a href="https://stackoverflow.com/questions/7436801/identifying-listening-ports-using-python">this question</a> and, particularly, on <a href="https://stackoverflow.com/a/7436912/276451">this answer</a>. Let's suppose I have a fixed list of services to check, say: <code>('ftp', 'ssh', 'http')</code>. Opening a socket to port 22 of a remote server:</p>
  
  <pre><code>import socket
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  result = s.connect_ex(('my_remote_server', 22))
  
  if(result == 0) :
      print s.recv(256)
  s.close()
  </code></pre>
  
  <p>I get the following output:</p>
  
  <pre><code>'SSH-2.0-OpenSSH_6.1p1 Debian-4\r\n'
  </code></pre>
  
  <p>So I can guess there's a ssh service listening on that port. Therefore my question is: where or how can I find the <em>welcome messages</em> (or similar) for different kind of services? Are these regulated in some way? In the case of ssh, does it always start with <code>SSH-</code>?</p>