class Net::SSH::Transport::ServerVersion

def negotiate!(socket, timeout)

exception.
reports an incompatible SSH version (e.g., SSH1), this will raise an
Negotiates the SSH protocol to use, via the given socket. If the server
def negotiate!(socket, timeout)
  info { "negotiating protocol version" }
  debug { "local is `#{PROTO_VERSION}'" }
  socket.write "#{PROTO_VERSION}\r\n"
  socket.flush
  if timeout && !IO.select([socket], nil, nil, timeout)
    raise Net::SSH::ConnectionTimeout, "timeout during server version negotiating"
  end
  loop do
    @version = ""
    loop do
      begin
        b = socket.readpartial(1)
        raise Net::SSH::Disconnect, "connection closed by remote host" if b.nil?
      rescue EOFError
        raise Net::SSH::Disconnect, "connection closed by remote host"
      end
      @version << b
      break if b == "\n"
    end
    break if @version.match(/^SSH-/)
    @header << @version
  end
  @version.chomp!
  debug { "remote is `#{@version}'" }
  unless @version.match(/^SSH-(1\.99|2\.0)-/)
    raise Net::SSH::Exception, "incompatible SSH version `#{@version}'"
  end
  if timeout && !IO.select(nil, [socket], nil, timeout)
    raise Net::SSH::ConnectionTimeout, "timeout during client version negotiating"
  end
end