Class: VagrantPlugins::GuestOmniOS::Cap::RemovePublicKey

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-guest-omnios/cap/remove_public_key.rb

Class Method Summary collapse

Class Method Details

.remove_public_key(machine, contents) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/vagrant-guest-omnios/cap/remove_public_key.rb', line 7

def self.remove_public_key(machine, contents)
  contents = contents.chomp
  contents = Vagrant::Util::ShellQuote.escape(contents, "'")

  machine.communicate.tap do |comm|
    if comm.test("test -f ~/.ssh/authorized_keys")
      comm.execute(
        "sed -i '/^.*#{contents}.*$/d' ~/.ssh/authorized_keys")
    end
  end
end