module Restic::Service::Targets::SSHTarget

Public Class Methods

new(name) click to toggle source
Calls superclass method
# File lib/restic/service/targets/ssh_target.rb, line 5
def initialize(name)
    super
    @key_path = nil
    @host = nil
    @username = nil
    @host_keys = []
end

Public Instance Methods

available?() click to toggle source
# File lib/restic/service/targets/ssh_target.rb, line 21
def available?
    ssh = SSHKeys.new
    actual_keys = ssh.query_keys(@host)
    valid?(actual_keys)
end
setup_from_conf(conf, yaml) click to toggle source
Calls superclass method
# File lib/restic/service/targets/ssh_target.rb, line 13
def setup_from_conf(conf, yaml)
    super
    @username  = yaml.fetch('username').to_str
    @host      = yaml.fetch('host').to_str
    @key_path  = conf.conf_keys_path_for(self)
    @host_keys = SSHKeys.load_keys_from_file(@key_path)
end
valid?(actual_keys) click to toggle source
# File lib/restic/service/targets/ssh_target.rb, line 27
def valid?(actual_keys)
    actual_keys.any? { |k| @host_keys.include?(k) }
end
with_ssh_config() { |ssh_config_name| ... } click to toggle source
# File lib/restic/service/targets/ssh_target.rb, line 31
def with_ssh_config
    ssh = SSHKeys.new
    ssh_config_name = ssh.ssh_setup_config(
        name, @username, @host, @key_path)
    yield(ssh_config_name)
ensure
    ssh.ssh_cleanup_config if ssh_config_name
end