Class: Vagrant::Solaris10::Cap::RemovePublicKey

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

Class Method Summary collapse

Class Method Details

.remove_public_key(machine, contents) ⇒ Object



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

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(
        "gsed -i '/^.*#{contents}.*$/d' ~/.ssh/authorized_keys")
    end
  end
end