Sha256: b773d12af1a09c13b6ea4310eaf7ed651a62eb2f3ba175bb29650d74779186bd

Contents?: true

Size: 623 Bytes

Versions: 4

Compression:

Stored size: 623 Bytes

Contents

require "vagrant/util/shell_quote"

module VagrantPlugins
  module GuestOpenBSD
    module Cap
      class InsertPublicKey
        def self.insert_public_key(machine, contents)
          contents = Vagrant::Util::ShellQuote.escape(contents, "'")
          contents = contents.gsub("\n", "\\n")

          machine.communicate.tap do |comm|
            comm.execute("mkdir -p ~/.ssh")
            comm.execute("chmod 0700 ~/.ssh")
            comm.execute("printf '#{contents}\\n' >> ~/.ssh/authorized_keys")
            comm.execute("chmod 0600 ~/.ssh/authorized_keys")
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vagrant-unbundled-1.8.4.2 plugins/guests/openbsd/cap/insert_public_key.rb
vagrant-unbundled-1.8.4.1 plugins/guests/openbsd/cap/insert_public_key.rb
vagrant-unbundled-1.8.1.2 plugins/guests/openbsd/cap/insert_public_key.rb
vagrant-unbundled-1.8.1.1 plugins/guests/openbsd/cap/insert_public_key.rb