[ssh] Setup SSH keys
change
commit 62f4712ec8be5f7ee91de2e57829fcc51d483790
author Alpha Chen <alpha.chen@gmail.com>
date
parent d3e810de
diff --git a/ansible/config.yml b/ansible/config.yml
index 2bcbf912..3ed74304 100644
--- a/ansible/config.yml
+++ b/ansible/config.yml
@@ -31,5 +31,5 @@
     with_dict:
       git/.gitignore: .gitignore
   - name: setup ssh keys
-    local_action: ruby ~/.dotfiles/setup_ssh_keys.rb
+    local_action: command ruby ~/.dotfiles/scripts/setup_ssh_keys.rb
     when: ansible_domain == "local"
diff --git a/scripts/setup_ssh_keys.rb b/scripts/setup_ssh_keys.rb
new file mode 100644
index 00000000..8d26af9b
--- /dev/null
+++ b/scripts/setup_ssh_keys.rb
@@ -0,0 +1,21 @@
+require 'fileutils'
+
+include FileUtils
+
+def with_mount(image)
+  out = `hdiutil mount #{image}`
+  mountpoint = out.split(/\s+/).last
+  yield(mountpoint)
+ensure
+  puts `hdiutil unmount #{mountpoint}`
+end
+
+cd File.expand_path('~/.ssh')
+
+with_mount "~/Dropbox/sekritz.sparseimage" do |mountpoint|
+  Dir["#{mountpoint}/ssh keys/*"].each do |file|
+    cp file, File.basename(file)
+    puts `chmod go-r #{File.basename(file)}`
+    puts `ssh-add -K #{File.basename(file)}`
+  end
+end