public Method

KnownHosts.keys_for(host)

There's no documentation for this item.

Source Code

# File net/ssh/known-hosts.rb, line 56
def keys_for(host)
  keys = []
  hosts = Array(host)

  File.open(source) do |file|
    scanner = StringScanner.new("")
    file.each_line do |line|
      scanner.string = line

      scanner.skip(/\s*/)
      next if scanner.match?(/$|#/)

      hostlist = scanner.scan(/\S+/)
      next if (hostlist.split(/,/) & hosts).empty?

      scanner.skip(/\s*/)
      type = scanner.scan(/\S+/)
      scanner.skip(/\s*/)
      blob = scanner.rest.unpack("m*").first
      keys << Net::SSH::Transport::OSSL::Buffer.new(blob).read_key
    end
  end

  keys
rescue SystemCallError
  return []
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.