vaguerent/plugins/guests/openwrt/cap/insert_public_key.rb
Jeff Bonhag 50d995f51d
Guest support for OpenWrt
This commit includes the following capabilties for OpenWrt:

- Guest detection
- SSH key replacement
- Change host name
- Rsync
2020-07-29 11:32:46 -04:00

21 lines
500 B
Ruby

require "vagrant/util/shell_quote"
module VagrantPlugins
module GuestOpenWrt
module Cap
class InsertPublicKey
def self.insert_public_key(machine, contents)
contents = contents.chomp
contents = Vagrant::Util::ShellQuote.escape(contents, "'")
machine.communicate.tap do |comm|
comm.execute <<~EOH
printf '#{contents}\\n' >> /etc/dropbear/authorized_keys
EOH
end
end
end
end
end
end