Skip to content

Commit ae0cd66

Browse files
committed
Merge pull request #82 from aried3r/ar/update_readme
Update README and use OpenSSH defaults for UseDNS
2 parents 1d90833 + 0f2fbe3 commit ae0cd66

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This cookbook provides secure ssh-client and ssh-server configurations.
1818

1919
* `['network']['ipv6']['enable']` - true if IPv6 is needed
2020
* `['ssh'][{'client', 'server'}]['cbc_required']` - true if CBC for ciphers is required. This is usually only necessary, if older M2M mechanism need to communicate with SSH, that don't have any of the configured secure ciphers enabled. CBC is a weak alternative. Anything weaker should be avoided and is thus not available.
21-
* `['ssh'][{'client', 'server'}]['weak_hmac']` - true if weaker HMAC mechanisms are required. This is usually only necessary, if older M2M mechanism need to communicate with SSH, that don't have any of the configured secure HMACs enabled.
21+
* `['ssh'][{'client', 'server'}]['weak_hmac']` - true if weaker HMAC mechanisms are required. This is usually only necessary, if older M2M mechanism need to communicate with SSH, that don't have any of the configured secure HMACs enabled.
2222
* `['ssh'][{'client', 'server'}]['weak_kex']` - true if weaker Key-Exchange (KEX) mechanisms are required. This is usually only necessary, if older M2M mechanism need to communicate with SSH, that don't have any of the configured secure KEXs enabled.
2323
* `['ssh']['allow_root_with_key']` - `false` to disable root login altogether. Set to `true` to allow root to login via key-based mechanism.
2424
* `['ssh']['ports']` - ports to which ssh-server should listen to and ssh-client should connect to
@@ -29,6 +29,11 @@ This cookbook provides secure ssh-client and ssh-server configurations.
2929
* `['ssh']['use_pam']` - `false` to disable pam authentication
3030
* `['ssh']['print_motd']` - `false` to disable printing of the MOTD
3131
* `['ssh']['print_last_log']` - `false` to disable display of last login information
32+
* `default['ssh']['deny_users']` - `[]` to configure `DenyUsers`, if specified login is disallowed for user names that match one of the patterns.
33+
* `default['ssh']['allow_users']` - `[]` to configure `AllowUsers`, if specified, login is allowed only for user names that match one of the patterns.
34+
* `default['ssh']['deny_groups']` - `[]` to configure `DenyGroups`, if specified, login is disallowed for users whose primary group or supplementary group list matches one of the patterns.
35+
* `default['ssh']['allow_groups']` - `[]` to configure `AllowGroups`, if specified, login is allowed only for users whose primary group or supplementary group list matches one of the patterns.
36+
* `default['ssh']['use_dns']` - `nil` to configure if sshd should look up the remote host name and check that the resolved host name for the remote IP address maps back to the very same IP address.
3237

3338
## Data Bags
3439

@@ -40,7 +45,7 @@ This cookbook used to handle authorized keys for the root user, but that support
4045

4146
Have users in your `data_bag/users/` directory. This cookbook looks for users inside this folder with a `ssh_rootkey`.
4247

43-
Example:
48+
Example:
4449

4550
First you have to find out the ssh-key of the user you want to allow. A typical example for this is
4651

@@ -66,7 +71,7 @@ You can then access
6671
## Usage
6772

6873
Add the recipes to the run_list:
69-
74+
7075
"recipe[ssh]"
7176

7277
This will install ssh-server and ssh-client. You can alternatively choose only one via:

attributes/default.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
default['ssh']['allow_groups'] = [] # sshd
6666
default['ssh']['print_motd'] = false # sshd
6767
default['ssh']['print_last_log'] = false # sshd
68-
default['ssh']['use_dns'] = true # sshd
68+
# set this to nil to let us use the default OpenSSH in case it's not set by the user
69+
default['ssh']['use_dns'] = nil # sshd
6970
# set this to nil to let us detect the attribute based on the node platform
7071
default['ssh']['use_privilege_separation'] = nil

spec/recipes/server_spec.rb

+16-3
Original file line numberDiff line numberDiff line change
@@ -473,13 +473,13 @@
473473
end
474474

475475
context 'without attribute use_dns' do
476-
it 'sets UseDNS to the default' do
476+
it 'leaves UseDNS commented' do
477477
expect(chef_run).to render_file('/etc/ssh/sshd_config')
478-
.with_content(/UseDNS yes/)
478+
.with_content(/#UseDNS no/)
479479
end
480480
end
481481

482-
context 'with attribute use_dns' do
482+
context 'with attribute use_dns set to false' do
483483
cached(:chef_run) do
484484
ChefSpec::ServerRunner.new do |node|
485485
node.set['ssh']['use_dns'] = false
@@ -491,4 +491,17 @@
491491
.with_content(/UseDNS no/)
492492
end
493493
end
494+
495+
context 'with attribute use_dns set to true' do
496+
cached(:chef_run) do
497+
ChefSpec::ServerRunner.new do |node|
498+
node.set['ssh']['use_dns'] = true
499+
end.converge(described_recipe)
500+
end
501+
502+
it 'sets UseDNS correctly' do
503+
expect(chef_run).to render_file('/etc/ssh/sshd_config')
504+
.with_content(/UseDNS yes/)
505+
end
506+
end
494507
end

templates/default/opensshd.conf.erb

+5
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,12 @@ X11UseLocalhost yes
185185
PrintMotd <%= ((@node['ssh']['print_motd']) ? 'yes' : 'no' ) %>
186186
PrintLastLog <%= ((@node['ssh']['print_last_log']) ? 'yes' : 'no' ) %>
187187
#Banner /etc/ssh/banner.txt
188+
<% if @node['ssh']['use_dns'].nil? %>
189+
# Since OpenSSH 6.8, this value defaults to 'no'
190+
#UseDNS no
191+
<% else %>
188192
UseDNS <%= ((@node['ssh']['use_dns']) ? 'yes' : 'no' ) %>
193+
<% end %>
189194
#PidFile /var/run/sshd.pid
190195
#MaxStartups 10
191196
#ChrootDirectory none

0 commit comments

Comments
 (0)