Skip to content

Commit 9881b48

Browse files
Merge pull request #174 from dev-sec/micheelengronne-patch-2
ssh host keys in a specific directory
2 parents 68cce04 + 884a397 commit 9881b48

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

controls/sshd_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
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')
3333
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')
34+
sshd_custom_hostkeys_path = attribute('sshd_custom_hostkeys_path', value: '/etc/ssh', description: 'Sometimes ssh host keys must be in a particular path, in a clustered environment for instance')
3435

3536
sshd_valid_privseparation = if sshd_custom_user != 'root'
3637
'no'
@@ -187,7 +188,7 @@
187188
title 'Server: Specify SSH HostKeys'
188189
desc 'Specify HostKey for protection against Man-In-The-Middle Attacks'
189190

190-
sshd_valid_hostkeys = ssh_crypto.valid_algorithms.map { |alg| "#{sshd_custom_path}/ssh_host_#{alg}_key" }
191+
sshd_valid_hostkeys = ssh_crypto.valid_algorithms.map { |alg| "#{sshd_custom_hostkeys_path}/ssh_host_#{alg}_key" }
191192
sshd_valid_hostkeys = sshd_valid_hostkeys[0] if sshd_valid_hostkeys.length == 1
192193

193194
describe sshd_config(sshd_custom_path + '/sshd_config') do

0 commit comments

Comments
 (0)