Skip to content

Commit

Permalink
Add option for extra SSH keys.
Browse files Browse the repository at this point in the history
  • Loading branch information
roidrage committed Apr 13, 2012
1 parent 928ed49 commit 58f16e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 12 additions & 1 deletion worker_host/users/recipes/default.rb
Expand Up @@ -56,7 +56,18 @@
end
end

ssh_keys = {}
if user[:ssh_key]
ssh_keys[user[:id]] = user[:ssh_key]
end

if user[:extra_ssh_keys]
user[:extra_ssh_keys].each do |user_id|
ssh_keys[user_id] = users.find{|user| user[:id] == user_id}[:ssh_key]
end
end

if ssh_keys.any?
directory "#{user[:home]}/.ssh" do
mode "0700"
owner user[:id]
Expand All @@ -69,7 +80,7 @@
owner user[:id]
group primary_group
source "authorized_keys.pub"
variables :ssh_key => user[:ssh_key]
variables :ssh_keys => ssh_keys
end
end
end
5 changes: 4 additions & 1 deletion worker_host/users/templates/default/authorized_keys.pub
@@ -1 +1,4 @@
<%= @ssh_key %>
<% @ssh_keys.each do |name, key| %>
# <%= name %>
<%= key %>
<% end %>

0 comments on commit 58f16e4

Please sign in to comment.