|
28 | 28 | sshd_x11forwarding = attribute('sshd_x11forwarding', value: 'no', description: 'Expected value for sshd_config X11Forwarding') |
29 | 29 | sshd_banner = attribute('sshd_banner', value: 'none', description: 'Expected value for sshd_config Banner') |
30 | 30 | sshd_max_auth_tries = attribute('sshd_max_auth_tries', value: 2, description: 'Expected value for max_auth_retries') |
| 31 | +sshd_custom_user = attribute('custom_user', value: 'root', description: 'The SSH user is not always root. It must be an unprivileged user in a container') |
| 32 | +sshd_custom_path = attribute('custom_path', value: '/etc/ssh', description: 'Sometimes ssh configuration files are present in another location and ssh use them with the -f flag') |
31 | 33 |
|
32 | 34 | only_if do |
33 | 35 | command('sshd').exist? |
|
63 | 65 | control 'sshd-04' do |
64 | 66 | impact 1.0 |
65 | 67 | title 'Server: Check SSH folder owner, group and permissions.' |
66 | | - desc 'The SSH folder should owned by root, only be writable by owner and readable by others.' |
67 | | - describe file('/etc/ssh') do |
| 68 | + desc 'The SSH folder should owned by root or a defined user, only be writable by owner and readable by others.' |
| 69 | + describe file(sshd_custom_path) do |
68 | 70 | it { should exist } |
69 | 71 | it { should be_directory } |
70 | 72 | it { should be_owned_by 'root' } |
71 | | - it { should be_grouped_into os.darwin? ? 'wheel' : 'root' } |
| 73 | + it { should be_grouped_into os.darwin? ? 'wheel' : sshd_custom_user } |
72 | 74 | it { should be_executable } |
73 | 75 | it { should be_readable.by('owner') } |
74 | 76 | it { should be_readable.by('group') } |
|
84 | 86 | title 'Server: Check sshd_config owner, group and permissions.' |
85 | 87 | desc 'The sshd_config should owned by root, only be writable/readable by owner and not be executable.' |
86 | 88 |
|
87 | | - describe file('/etc/ssh/sshd_config') do |
| 89 | + describe file(sshd_custom_path + '/sshd_config') do |
88 | 90 | it { should exist } |
89 | 91 | it { should be_file } |
90 | 92 | it { should be_owned_by 'root' } |
|
481 | 483 | impact 1.0 |
482 | 484 | title 'Server: DH primes' |
483 | 485 | desc 'Verifies if strong DH primes are used in /etc/ssh/moduli' |
484 | | - describe bash("test $(awk '$5 < 2047 && $5 ~ /^[0-9]+$/ { print $5 }' /etc/ssh/moduli | uniq | wc -c) -eq 0") do |
| 486 | + describe bash("test $(awk '$5 < 2047 && $5 ~ /^[0-9]+$/ { print $5 }' " + sshd_custom_path + "/moduli | uniq | wc -c) -eq 0") do |
485 | 487 | its('exit_status') { should eq 0 } |
486 | 488 | its('stdout') { should eq '' } |
487 | 489 | its('stderr') { should eq '' } |
|
0 commit comments