dev-sec / ansible-collection-hardening

This Ansible collection provides battle tested hardening for Linux, SSH, nginx, MySQL

Home Page:http://dev-sec.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

playbook makes OS undetectable

kidbrax opened this issue · comments

I launched an AWS Linux AMI, ami-275ffe31, which is their ECS-optimized image. Inspec detects it as a AWS box. But then when I run this playbook, Inspec can no longer detect the OS. When I run Inspec detect after running this playbook, I get:

== Operating System Details

Name:      
Family:    unknown
Release:   
Arch:      This account is currently not available.

Is this expected behavior? Or has anyone else seen similar behavior? I basically can't use Inspec anymore after running this playbook.

With what account do you run inspec? The message This account is currently not available looks like there's a problem logging in.

The account is ec2-user. It works before I run the playbook, but then fails after the playbook has been run with the above output.

To clarify, that is the user I'm connecting with, the ssh user. Not the user on my local machine.

FYI, this passes before the playbook is run but not after.
test -f /etc/system-release && cat /etc/system-release
That seems to be what keeps inspec from getting the right OS.

I'll spin up a instance on AWS and check it.

We're also seeing this with the official Centos 6 image. Inspec runs fine on a bare box, but after applying this playbook, the test fails with:
Failed to complete #verify action: [This OS/platform () is not supported by this profile.] on dev-sec-centos6

Adding the default user of your AMI to the ignore_users seems to do the trick. So for us:
os_ignore_users: ['centos']

Would be good if this could be included in this list from the auto-detected user, or even just added to the readme.

Thanks for the clarification, @HenryTheHamster.

Would be good if this could be included in this list from the auto-detected user

For centos-machines it seems to be the user centos, for ubuntu the user ubuntu. However I could not find the user for other operating systems.

I also do not want to exclude a list of users as this would weaken the hardening. So I guess your proposal to add this to the readme is the best option. Would you mind opening a PR for this?