Skip to content

Commit 81a5c8d

Browse files
Merge pull request #164 from dev-sec/micheelengronne-patch-3
sshd custom port
2 parents 671dada + 3b25ee4 commit 81a5c8d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

controls/sshd_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
sshd_max_auth_tries = attribute('sshd_max_auth_tries', value: 2, description: 'Expected value for max_auth_retries')
3131
sshd_custom_user = attribute('sshd_custom_user', value: 'root', description: 'The SSH user is not always root. It must be an unprivileged user in a container')
3232
sshd_custom_path = attribute('sshd_custom_path', value: '/etc/ssh', description: 'Sometimes ssh configuration files are present in another location and ssh use them with the -f flag')
33+
sshd_custom_port = attribute('sshd_custom_port', value: '22', description: 'Sometimes the ssh port is not 22. For instance, in a container as another user, 22 is forbidden')
3334

3435
sshd_valid_privseparation = if sshd_custom_user != 'root'
3536
'no'
@@ -121,7 +122,7 @@
121122
title 'Server: Specify the listen ssh Port'
122123
desc 'Always specify which port the SSH server should listen to. Prevent unexpected settings.'
123124
describe sshd_config(sshd_custom_path + '/sshd_config') do
124-
its('Port') { should eq('22') }
125+
its('Port') { should eq(sshd_custom_port) }
125126
end
126127
end
127128

0 commit comments

Comments
 (0)