From 62f4712ec8be5f7ee91de2e57829fcc51d483790 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Thu, 24 Jul 2014 20:42:45 -0700 Subject: [PATCH] [ssh] Setup SSH keys --- ansible/config.yml | 2 +- scripts/setup_ssh_keys.rb | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 scripts/setup_ssh_keys.rb diff --git a/ansible/config.yml b/ansible/config.yml index 2bcbf91..3ed7430 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 0000000..8d26af9 --- /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