Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymzh committed Jul 2, 2020
1 parent 1754536 commit eea046d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 9 additions & 0 deletions cookbooks/fb_ssh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ These work similarly to Authorized Principals. If you set
There should be one item for each user, as many keys as you'd like may
be in that item.

Alternatively you can populate `node['fb_ssh']['authorized_keys'][$USER]`.
Doing so should be done similarly to the databags and each key given a name:

```ruby
node.default['fb_ssh']['authorized_keys']['john']['key1'] = '...'
```

Anything in the node overrides databags.

### Client config (ssh_config)
The client config works the same as the server config, except the special-case
is `Host` keys instead of `Match` keys. As an example:
Expand Down
5 changes: 4 additions & 1 deletion cookbooks/fb_ssh/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@
mode '0644'
variables({ :type => 'sshd_config' })
verify '/usr/sbin/sshd -t -f %{path}'
notifies :restart, 'service[ssh]'
# in firstboot we may not be able to get in until ssh is restarted
# on the desired config, so restart immediately. Otherwise, delay
ntype = node.firstboot_any_phase? ? :immediately : :delayed
notifies :restart, 'service[ssh]', ntype
end

template '/etc/ssh/ssh_config' do
Expand Down
3 changes: 2 additions & 1 deletion cookbooks/fb_ssh/resources/authorization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def manage(type)
auth_map = Hash[
data_bag('fb_ssh_authorized_keys').map { |x| [x, nil] }
]
auth_map.merge!(node['fb_ssh']['authorized_keys'])
else
auth_map = node['fb_ssh']["authorized_#{type}"]
end
Expand All @@ -44,7 +45,7 @@ def manage(type)
owner 'root'
group 'root'
mode '0644'
if type == 'keys'
if type == 'keys' && !auth_map[user]
d = data_bag_item('fb_ssh_authorized_keys', user)
d.delete('id')
variables({ :data => d })
Expand Down

0 comments on commit eea046d

Please sign in to comment.