2020-07-17 16:31:46 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-09-16 20:28:05 +02:00
|
|
|
# Overide by Platform
|
2019-10-27 01:02:33 +02:00
|
|
|
root_group =
|
|
|
|
case platform[:family]
|
|
|
|
when 'bsd'
|
|
|
|
'wheel'
|
|
|
|
else
|
|
|
|
'root'
|
|
|
|
end
|
2019-09-16 20:28:05 +02:00
|
|
|
|
2020-07-21 10:52:03 +02:00
|
|
|
github_known_host = 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGm[...]'
|
|
|
|
gitlab_known_host_re = /gitlab.com,[0-9a-f.:,]* ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABA/
|
|
|
|
minion_rsa_known_host = 'minion.id,alias.of.minion.id ssh-rsa [...]'
|
|
|
|
minion_ed25519_known_host = 'minion.id,alias.of.minion.id ssh-ed25519 [...]'
|
|
|
|
|
2019-09-16 20:28:05 +02:00
|
|
|
control 'openssh configuration' do
|
|
|
|
title 'should match desired lines'
|
|
|
|
|
|
|
|
describe file('/etc/ssh/sshd_config') do
|
|
|
|
it { should be_file }
|
|
|
|
its('mode') { should cmp '0644' }
|
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
it { should be_grouped_into root_group }
|
|
|
|
its('content') { should include 'ChallengeResponseAuthentication no' }
|
|
|
|
its('content') { should include 'X11Forwarding yes' }
|
|
|
|
its('content') { should include 'PrintMotd no' }
|
|
|
|
its('content') { should include 'AcceptEnv LANG LC_*' }
|
|
|
|
its('content') { should include 'Subsystem sftp /usr/lib/openssh/sftp-server' }
|
|
|
|
its('content') { should include 'UsePAM yes' }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe file('/etc/ssh/ssh_config') do
|
|
|
|
it { should be_file }
|
|
|
|
its('mode') { should cmp '0644' }
|
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
it { should be_grouped_into root_group }
|
|
|
|
its('content') { should include 'Host *' }
|
|
|
|
its('content') { should include ' GSSAPIAuthentication yes' }
|
|
|
|
its('content') { should include ' HashKnownHosts yes' }
|
|
|
|
its('content') { should include ' SendEnv LANG LC_*' }
|
|
|
|
end
|
2020-07-21 10:52:03 +02:00
|
|
|
|
|
|
|
describe file('/etc/ssh/ssh_known_hosts') do
|
|
|
|
it { should be_file }
|
|
|
|
its('mode') { should cmp '0644' }
|
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
it { should be_grouped_into 'root' }
|
|
|
|
its('content') { should include github_known_host }
|
|
|
|
its('content') { should match(gitlab_known_host_re) }
|
|
|
|
its('content') { should include minion_rsa_known_host }
|
|
|
|
its('content') { should include minion_ed25519_known_host }
|
|
|
|
end
|
2019-09-16 20:28:05 +02:00
|
|
|
end
|