Skip to content

Commit 7ea7034

Browse files
Tests and docs for dev-secGH-126
1 parent 2a8d483 commit 7ea7034

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ This cookbook provides secure ssh-client and ssh-server configurations. This coo
4646
* `['ssh-hardening']['ssh']['print_motd']` - `false` to disable printing of the MOTD
4747
* `['ssh-hardening']['ssh']['print_last_log']` - `false` to disable display of last login information
4848
* `['ssh-hardening']['ssh']['banner']` - `nil` to disable banner or provide a path like '/etc/issue.net'
49+
* `['ssh-hardening']['ssh']['os_banner']` - `false` to disable version information during the protocol handshake (debian family only)
4950
* `['ssh-hardening']['ssh']['max_auth_tries']` - controls `MaxAuthTries`; the number of authentication attempts per connection.
5051
* `['ssh-hardening']['ssh']['max_sessions']` - controls `MaxSessions`; the number of sessions per connection.
5152
* `['ssh-hardening']['ssh']['deny_users']` - `[]` to configure `DenyUsers`, if specified login is disallowed for user names that match one of the patterns.

spec/recipes/server_spec.rb

+37
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,43 @@
211211
end
212212
end
213213

214+
describe 'debian banner' do
215+
cached(:chef_run) do
216+
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04').converge(described_recipe)
217+
end
218+
219+
it 'disables the debian banner' do
220+
expect(chef_run).to render_file('/etc/ssh/sshd_config').
221+
with_content(/DebianBanner no/)
222+
end
223+
224+
context 'with enabled debian banner' do
225+
cached(:chef_run) do
226+
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '16.04') do |node|
227+
node.normal['ssh-hardening']['ssh']['os_banner'] = true
228+
end.converge(described_recipe)
229+
end
230+
231+
it 'uses the enabled debian banner' do
232+
expect(chef_run).to render_file('/etc/ssh/sshd_config').
233+
with_content(/DebianBanner yes/)
234+
end
235+
end
236+
237+
context 'with centos as platform' do
238+
cached(:chef_run) do
239+
ChefSpec::ServerRunner.new(platform: 'centos', version: '7.2.1511') do |node|
240+
node.normal['ssh-hardening']['ssh']['os_banner'] = true
241+
end.converge(described_recipe)
242+
end
243+
244+
it 'does not have the debian banner option' do
245+
expect(chef_run).not_to render_file('/etc/ssh/sshd_config').
246+
with_content(/DebianBanner/)
247+
end
248+
end
249+
end
250+
214251
it 'leaves deny users commented' do
215252
expect(chef_run).to render_file('/etc/ssh/sshd_config').
216253
with_content(/#DenyUsers */)

0 commit comments

Comments
 (0)