class Net::SSH::KnownHosts

def add(host, key, options={})

to.
add an entry for the given host and key to the first file it is able
Looks in all user known host files (see KnownHosts.hostfiles) and tries to
def add(host, key, options={})
  hostfiles(options, :user).each do |file|
    begin
      KnownHosts.new(file).add(host, key)
      return
    rescue SystemCallError
      # try the next hostfile
    end
  end
end