Skip to content

Commit b9c4667

Browse files
custom path for hostkeys
Signed-off-by: Michée Lengronne <michee.lengronne@coppint.com>
1 parent 723ec9b commit b9c4667

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

libraries/ssh_crypto.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
# author: Dominik Richter
1717
# author: Patrick Muench
1818

19+
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')
20+
1921
class SshCrypto < Inspec.resource(1) # rubocop:disable Metrics/ClassLength
2022
name 'ssh_crypto'
2123

@@ -256,7 +258,7 @@ def valid_algorithms # rubocop:disable Metrics/CyclomaticComplexity
256258

257259
# returns the hostkeys value based on valid_algorithms
258260
def valid_hostkeys
259-
hostkeys = valid_algorithms.map { |alg| "/etc/ssh/ssh_host_#{alg}_key" }
261+
hostkeys = valid_algorithms.map { |alg| "#{sshd_custom_path}/ssh_host_#{alg}_key" }
260262
# its('HostKey') provides a string for a single-element value.
261263
# we have to return a string if we have a single-element
262264
# https://github.com/chef/inspec/issues/1434

0 commit comments

Comments
 (0)