Class: RunSSHLib::SshBackend::KnownHostsUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/runsshlib/ssh_backend.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(known_hosts_file = File.expand_path('~/.ssh/known_hosts')) ⇒ KnownHostsUtils

Returns a new instance of KnownHostsUtils.



27
28
29
# File 'lib/runsshlib/ssh_backend.rb', line 27

def initialize(known_hosts_file=File.expand_path('~/.ssh/known_hosts'))
  @known_hosts_file = known_hosts_file
end

Instance Attribute Details

#known_hosts_fileObject (readonly)

Returns the value of attribute known_hosts_file.



25
26
27
# File 'lib/runsshlib/ssh_backend.rb', line 25

def known_hosts_file
  @known_hosts_file
end

Instance Method Details

#delete_line_from_known_hosts_file(line_number) ⇒ Object



31
32
33
34
35
# File 'lib/runsshlib/ssh_backend.rb', line 31

def delete_line_from_known_hosts_file(line_number)
  `sed -i -e "#{line_number}d" #{@known_hosts_file}`
  raise 'Error deleting line from known_hosts file! See output for details' unless
        $? == 0
end