Skip to content

Commit 5fa902c

Browse files
authored
Merge pull request #159 from artem-sidorenko/log-level
Allow log level configuration of sshd
2 parents 4e38ef0 + ed06e16 commit 5fa902c

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ override['ssh-hardening']['ssh']['server']['listen_to'] = node['ipaddress']
6767
* `['ssh-hardening']['ssh']['server']['max_auth_tries']` - `2`. The number of authentication attempts per connection
6868
* `['ssh-hardening']['ssh']['server']['max_sessions']` - `10` The number of sessions per connection
6969
* `['ssh-hardening']['ssh']['server']['password_authentication']` - `false`. Set to `true` if password authentication should be enabled
70+
* `['ssh-hardening']['ssh']['server']['log_level']` - `verbose`. The log level of sshd. See `LogLevel` in `man 5 sshd_config` for possible values.
7071
* `['ssh-hardening']['ssh']['server']['sftp']['enable']` - `false`. Set to `true` to enable the SFTP feature of OpenSSH daemon
7172
* `['ssh-hardening']['ssh']['server']['sftp']['group']` - `sftponly`. Sets the `Match Group` option of SFTP to allow SFTP only for dedicated users
7273
* `['ssh-hardening']['ssh']['server']['sftp']['chroot']` - `/home/%u`. Sets the directory where the SFTP user should be chrooted

attributes/default.rb

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
default['ssh-hardening']['ssh']['server']['max_auth_tries'] = 2
9494
default['ssh-hardening']['ssh']['server']['max_sessions'] = 10
9595
default['ssh-hardening']['ssh']['server']['password_authentication'] = false
96+
default['ssh-hardening']['ssh']['server']['log_level'] = 'verbose'
9697
# sshd sftp options
9798
default['ssh-hardening']['ssh']['server']['sftp']['enable'] = false
9899
default['ssh-hardening']['ssh']['server']['sftp']['group'] = 'sftponly'

spec/recipes/server_spec.rb

+18
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,24 @@
404404
end
405405
end
406406

407+
it 'sets the log level to verbose' do
408+
expect(chef_run).to render_file('/etc/ssh/sshd_config').
409+
with_content('LogLevel VERBOSE')
410+
end
411+
412+
context 'with log level set to debug' do
413+
cached(:chef_run) do
414+
ChefSpec::ServerRunner.new do |node|
415+
node.normal['ssh-hardening']['ssh']['server']['log_level'] = 'debug'
416+
end.converge(described_recipe)
417+
end
418+
419+
it 'sets the log level to debug' do
420+
expect(chef_run).to render_file('/etc/ssh/sshd_config').
421+
with_content('LogLevel DEBUG')
422+
end
423+
end
424+
407425
it 'leaves deny users commented' do
408426
expect(chef_run).to render_file('/etc/ssh/sshd_config').
409427
with_content(/#DenyUsers */)

templates/default/opensshd.conf.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ StrictModes yes
4848

4949
# Logging, obsoletes QuietMode and FascistLogging
5050
SyslogFacility AUTH
51-
LogLevel VERBOSE
51+
LogLevel <%= @node['ssh-hardening']['ssh']['server']['log_level'].upcase %>
5252

5353
# Cryptography
5454
# ------------

0 commit comments

Comments
 (0)