Sha256: 68c07f8defa5c1a8cd41a741dbe776c0af346dfccfb3996fe0ef38ce909bac23

Contents?: true

Size: 753 Bytes

Versions: 3

Compression:

Stored size: 753 Bytes

Contents

require "vagrant/util/shell_quote"

module VagrantPlugins
  module GuestSolaris
    module Cap
      class RemovePublicKey
        def self.remove_public_key(machine, contents)
          # "sed -i" is specific to GNU sed and is not a posix standard option
          contents = contents.chomp
          contents = Vagrant::Util::ShellQuote.escape(contents, "'")

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

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/guests/solaris/cap/remove_public_key.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/guests/solaris/cap/remove_public_key.rb
vagrant-unbundled-2.3.3.0 plugins/guests/solaris/cap/remove_public_key.rb