X-Git-Url: https://pwan.org/git/?p=vagrant-dotfiles.git;a=blobdiff_plain;f=lib%2Fcopy_my_conf%2Fssh.rb;h=c45aba5a24c8f384a49c2ce68474726da285fceb;hp=bbe722df9cbf5e7eb5dc25fa619ecfa47350b748;hb=7adf63265cfc7d78bf36412e0ac0f480dd689678;hpb=2254852606b5104c60f643724a827701ae0c9c81 diff --git a/lib/copy_my_conf/ssh.rb b/lib/copy_my_conf/ssh.rb index bbe722d..c45aba5 100644 --- a/lib/copy_my_conf/ssh.rb +++ b/lib/copy_my_conf/ssh.rb @@ -1,20 +1,16 @@ -module Vagrant - module Provisioners - class CopyMyConf < Base - class Ssh - def prepare vm, tmp_root - vm.share_folder("ssh", "#{tmp_root}/ssh", "~/.ssh") - end - - def provision channel, user_home, tmp_root - puts "Copying your ssh keys and config" - channel.sudo("mkdir -p #{tmp_root}/cached && chown -R vagrant #{tmp_root}/cached") - channel.execute("[[ -f #{user_home}/.ssh/authorized_keys ]] && mv #{user_home}/.ssh/authorized_keys #{tmp_root}/cached") - channel.execute("cp #{tmp_root}/ssh/* #{user_home}/.ssh") - channel.execute("cat #{tmp_root}/cached/authorized_keys >> #{user_home}/.ssh/authorized_keys") # So that `vagrant ssh` doesn't ask for password - end +module CopyMyConf + class Ssh + def prepare vm, tmp_root + vm.synced_folder("#{tmp_root}/ssh", "~/.ssh", :id => "ssh") + end - end + def provision channel, user_home, tmp_root + puts "Copying your ssh keys and config" + channel.sudo("mkdir -p #{tmp_root}/cached && chown -R vagrant #{tmp_root}/cached") + channel.execute("[[ -f #{user_home}/.ssh/authorized_keys ]] && mv #{user_home}/.ssh/authorized_keys #{tmp_root}/cached") + channel.execute("cp #{tmp_root}/ssh/* #{user_home}/.ssh") + channel.execute("cat #{tmp_root}/cached/authorized_keys >> #{user_home}/.ssh/authorized_keys") # So that `vagrant ssh` doesn't ask for password end + end end