class Net::SSH::KnownHosts

def keys_for(host, options = {})

"[net.ssh.test]:5555,[1.2.3.4]:5555
"[1,2,3,4]:5555"
"[net.ssh.test]:5555"
"net.ssh.test,1.2.3.4"
"1.2.3.4"
"net.ssh.test"

after a colon. Possible formats for +host+, then, are;
both) in square brackets, and appending the port outside the brackets
port is being used, it may be specified by putting the host (or ip, or
of the host, or both (comma-separated). Additionally, if a non-standard
given host. The +host+ parameter is either the domain name or ip address
Returns an array of all keys that are known to be associatd with the
def keys_for(host, options = {})
  keys = []
  return keys unless File.readable?(source)
  entries = host.split(/,/)
  host_name = entries[0]
  host_ip = entries[1]
  File.open(source) do |file|
    file.each_line do |line|
      if line.start_with?('@')
        marker, hosts, type, key_content, comment = line.split(' ')
      else
        marker = nil
        hosts, type, key_content, comment = line.split(' ')
      end
      # Skip empty line or one that is commented
      next if hosts.nil? || hosts.start_with?('#')
      hostlist = hosts.split(',')
      next unless SUPPORTED_TYPE.include?(type)
      found = hostlist.any? { |pattern| match(host_name, pattern) } || known_host_hash?(hostlist, entries)
      next unless found
      found = hostlist.include?(host_ip) if options[:check_host_ip] && entries.size > 1 && hostlist.size > 1
      next unless found
      blob = key_content.unpack("m*").first
      raw_key = Net::SSH::Buffer.new(blob).read_key
      keys <<
        if marker == "@cert-authority"
          HostKeyEntries::CertAuthority.new(raw_key, comment: comment)
        else
          HostKeyEntries::PubKey.new(raw_key, comment: comment)
        end
    end
  end
  keys
end