Class: RunSSHLib::SshBackend::KnownHostsUtils
- Inherits:
-
Object
- Object
- RunSSHLib::SshBackend::KnownHostsUtils
- Defined in:
- lib/runsshlib/ssh_backend.rb
Instance Attribute Summary collapse
-
#known_hosts_file ⇒ Object
readonly
Returns the value of attribute known_hosts_file.
Instance Method Summary collapse
- #delete_line_from_known_hosts_file(line_number) ⇒ Object
-
#initialize(known_hosts_file = File.expand_path('~/.ssh/known_hosts')) ⇒ KnownHostsUtils
constructor
A new instance of KnownHostsUtils.
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.('~/.ssh/known_hosts')) @known_hosts_file = known_hosts_file end |
Instance Attribute Details
#known_hosts_file ⇒ Object (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 |