forked from dev-sec/ansible-collection-hardening
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dev-sec#162 from dev-sec/refactor
yaml-lint update, refactor tasks
- Loading branch information
Showing
10 changed files
with
200 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
driver: | ||
name: ec2 | ||
vpc_id: "vpc-4ef2ce26" | ||
subnet_id: "subnet-b477b7df" | ||
region: eu-central-1 | ||
|
||
transport: | ||
max_ssh_sessions: 5 | ||
|
||
provisioner: | ||
name: ansible_playbook | ||
hosts: all | ||
require_ansible_repo: false | ||
require_chef_for_busser: false | ||
require_ruby_for_busser: false | ||
require_ansible_omnibus: true | ||
ansible_verbose: true | ||
ansible_diff: true | ||
hosts: all | ||
roles_path: ../ansible-ssh-hardening/ | ||
http_proxy: <%= ENV['http_proxy'] || nil %> | ||
https_proxy: <%= ENV['https_proxy'] || nil %> | ||
playbook: default.yml | ||
|
||
platforms: | ||
- name: centos-7 | ||
- name: ubuntu-16.04 | ||
|
||
verifier: | ||
name: inspec | ||
sudo: true | ||
inspec_tests: | ||
- https://github.com/dev-sec/tests-ssh-hardening | ||
|
||
suites: | ||
- name: os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
# Install the 2FA packages and setup the config in PAM and SSH | ||
- name: Install google authenticator PAM module | ||
apt: | ||
name: 'libpam-google-authenticator' | ||
state: present | ||
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' | ||
|
||
- name: Install google authenticator PAM module | ||
yum: | ||
name: 'google-authenticator' | ||
state: present | ||
when: ansible_os_family == 'RedHat' or ansible_os_family == 'Oracle Linux' | ||
|
||
- name: Add google auth module to PAM | ||
pamd: | ||
name: 'sshd' | ||
type: 'auth' | ||
control: 'required' | ||
module_path: 'pam_google_authenticator.so' | ||
|
||
- name: Remove password auth from PAM | ||
pamd: | ||
name: 'sshd' | ||
type: 'auth' | ||
control: 'substack' | ||
module_path: 'password-auth' | ||
state: absent | ||
when: ansible_distribution == 'RedHat' or ansible_distribution == 'Oracle Linux' or ansible_distribution == 'Amazon' | ||
|
||
- name: Remove password auth from PAM | ||
replace: | ||
dest: '/etc/pam.d/sshd' | ||
regexp: '^@include common-auth' | ||
replace: '#@include common-auth' | ||
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,27 @@ | ||
--- | ||
- name: Set ssh CA pub keys | ||
template: src='trusted_user_ca_keys.j2' dest="{{ ssh_trusted_user_ca_keys_file }}" mode=0644 owner="{{ ssh_owner }}" group="{{ ssh_group }}" | ||
template: | ||
src: 'trusted_user_ca_keys.j2' | ||
dest: '{{ ssh_trusted_user_ca_keys_file }}' | ||
mode: '0644' | ||
owner: '{{ ssh_owner }}' | ||
group: '{{ ssh_group }}' | ||
notify: restart sshd | ||
|
||
- name: Create ssh authorized principals directories | ||
file: path="{{ item.path | dirname }}" mode="{{ item.directorymode | default(0700) }}" owner="{{ item.directoryowner | default(ssh_owner) }}" group="{{ item.directorygroup | default(ssh_group) }}" state=directory | ||
with_items: "{{ ssh_authorized_principals }}" | ||
file: | ||
path: '{{ item.path | dirname }}' | ||
mode: '{{ item.directorymode | default(0700) }}' | ||
owner: '{{ item.directoryowner | default(ssh_owner) }}' | ||
group: '{{ item.directorygroup | default(ssh_group) }}' | ||
state: directory | ||
with_items: '{{ ssh_authorized_principals }}' | ||
|
||
- name: Set ssh authorized principals | ||
template: src='authorized_principals.j2' dest="{{ item.path }}" mode="{{ item.filemode | default(0600) }}" owner="{{ item.owner| default(ssh_owner) }}" group="{{ item.group | default(ssh_group) }}" | ||
with_items: "{{ ssh_authorized_principals }}" | ||
template: | ||
src: 'authorized_principals.j2' | ||
dest: '{{ item.path }}' | ||
mode: '{{ item.filemode | default(0600) }}' | ||
owner: '{{ item.owner| default(ssh_owner) }}' | ||
group: '{{ item.group | default(ssh_group) }}' | ||
with_items: '{{ ssh_authorized_principals }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.