Now supporting vagrant 1.2. Simplified config class. SSH not working
[vagrant-dotfiles.git] / lib / copy_my_conf / ssh.rb
1 module CopyMyConf
2 class Ssh
3 def prepare vm, tmp_root
4 vm.synced_folder("#{tmp_root}/ssh", "~/.ssh", :id => "ssh")
5 end
6
7 def provision channel, user_home, tmp_root
8 puts "Copying your ssh keys and config"
9 channel.sudo("mkdir -p #{tmp_root}/cached && chown -R vagrant #{tmp_root}/cached")
10 channel.execute("[[ -f #{user_home}/.ssh/authorized_keys ]] && mv #{user_home}/.ssh/authorized_keys #{tmp_root}/cached")
11 channel.execute("cp #{tmp_root}/ssh/* #{user_home}/.ssh")
12 channel.execute("cat #{tmp_root}/cached/authorized_keys >> #{user_home}/.ssh/authorized_keys") # So that `vagrant ssh` doesn't ask for password
13 end
14
15 end
16 end