Class: SSHKit::Backend::Netssh::KnownHosts

Inherits:
Object
  • Object
show all
Includes:
Mutex_m
Defined in:
lib/sshkit/backends/netssh/known_hosts.rb

Instance Method Summary collapse

Constructor Details

#initializeKnownHosts

Returns a new instance of KnownHosts.



113
114
115
116
# File 'lib/sshkit/backends/netssh/known_hosts.rb', line 113

def initialize
  super()
  @files = {}
end

Instance Method Details

#add(*args) ⇒ Object



125
126
127
128
# File 'lib/sshkit/backends/netssh/known_hosts.rb', line 125

def add(*args)
  ::Net::SSH::KnownHosts.add(*args)
  synchronize { @files = {} }
end

#search_for(host, options = {}) ⇒ Object



118
119
120
121
122
123
# File 'lib/sshkit/backends/netssh/known_hosts.rb', line 118

def search_for(host, options = {})
  keys = ::Net::SSH::KnownHosts.hostfiles(options).map do |path|
    known_hosts_file(path).keys_for(host)
  end.flatten
  ::Net::SSH::HostKeys.new(keys, host, self, options)
end