Skip to content
This repository was archived by the owner on Dec 26, 2020. It is now read-only.

Commit 00aa9ea

Browse files
authored
Merge branch 'master' into deprecated-always_run
2 parents 83c1662 + 490be55 commit 00aa9ea

19 files changed

+333
-165
lines changed

.gitignore

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
README.pdf
2-
README.html
3-
shared_test_repo/
4-
test/integration
51
.kitchen
6-
coverage
7-
Vagrantfile.erb
8-
9-
Gemfile.lock
10-
Berksfile.lock
11-
12-
ansible.cfg
132
hosts
3+
Gemfile.lock

.kitchen.vagrant.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
---
22
driver:
33
name: vagrant
4+
driver_config:
5+
http_proxy: <%= ENV['http_proxy'] || nil %>
6+
https_proxy: <%= ENV['https_proxy'] || nil %>
7+
vagrantfiles:
8+
- kitchen_vagrant_block.rb
49

510
provisioner:
611
name: ansible_playbook
7-
test_repo_uri: https://github.com/hardening-io/tests-ssh-hardening.git
812
hosts: all
913
require_ansible_repo: false
1014
require_ansible_omnibus: true
@@ -13,6 +17,11 @@ provisioner:
1317
ansible_verbose: true
1418
roles_path: ../ansible-ssh-hardening/
1519
playbook: default.yml
20+
http_proxy: <%= ENV['http_proxy'] || nil %>
21+
https_proxy: <%= ENV['https_proxy'] || nil %>
22+
23+
transport:
24+
max_ssh_sessions: 5
1625

1726
platforms:
1827
- name: ubuntu-12.04
@@ -23,14 +32,25 @@ platforms:
2332
driver_config:
2433
box: opscode-ubuntu-14.04
2534
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box
35+
- name: ubuntu-16.04
36+
driver_config:
37+
box: opscode-ubuntu-16.04
38+
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-16.04_chef-provisionerless.box
2639
- name: centos-6.4
40+
- name: centos-7.2
2741
driver_config:
28-
box: opscode-centos-6.4
29-
box_url: https://opscode-vm.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box
42+
box: opscode-centos-7.2
43+
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.2_chef-provisionerless.box
3044
- name: centos-6.5
3145
driver_config:
3246
box: opscode-centos-6.5
3347
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-6.5_chef-provisionerless.box
48+
- name: centos-6.8
49+
driver_config:
50+
box: bento/centos-6.8
51+
- name: centos-7
52+
driver_config:
53+
box: bento/centos-7.2
3454
- name: oracle-6.4
3555
driver_config:
3656
box: oracle-6.4
@@ -39,10 +59,9 @@ platforms:
3959
driver_config:
4060
box: oracle-6.5
4161
box_url: https://storage.us2.oraclecloud.com/v1/istoilis-istoilis/vagrant/oel65-64.box
42-
- name: debian-6
62+
- name: oracle-7
4363
driver_config:
44-
box: debian-6
45-
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-6.0.10_chef-provisionerless.box
64+
box: boxcutter/ol72
4665
- name: debian-7
4766
driver_config:
4867
box: debian-7
@@ -56,10 +75,7 @@ verifier:
5675
name: inspec
5776
sudo: true
5877
inspec_tests:
59-
- https://github.com/dev-sec/tests-ssh-hardening
78+
- https://github.com/dev-sec/ssh-baseline/
6079

6180
suites:
62-
- name: ssh-ansible_1.9
63-
provisioner:
64-
ansible_version: 1.9.4
65-
- name: ssh-ansible_latest
81+
- name: ssh

.kitchen.yml

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,81 @@
11
---
22
driver:
33
name: docker
4-
privileged: true
54
use_sudo: false
6-
provision_command:
7-
- "mkdir /var/run/sshd"
5+
privileged: true
6+
http_proxy: <%= ENV['http_proxy'] || nil %>
7+
https_proxy: <%= ENV['https_proxy'] || nil %>
8+
9+
transport:
10+
max_ssh_sessions: 5
11+
12+
transport:
13+
max_ssh_sessions: 5
14+
815

916
provisioner:
1017
name: ansible_playbook
1118
hosts: all
1219
require_ansible_repo: false
13-
require_ansible_omnibus: true
1420
require_chef_for_busser: false
1521
require_ruby_for_busser: false
1622
ansible_verbose: true
1723
ansible_diff: true
1824
hosts: all
1925
roles_path: ../ansible-ssh-hardening/
26+
http_proxy: <%= ENV['http_proxy'] || nil %>
27+
https_proxy: <%= ENV['https_proxy'] || nil %>
2028
playbook: default.yml
29+
ansible_extra_flags:
30+
- "--skip-tags=sysctl"
2131

2232
platforms:
23-
- name: ubuntu-12.04
33+
- name: centos6-ansible-latest
34+
driver:
35+
image: rndmh3ro/docker-centos6-ansible:latest
36+
platform: centos
37+
- name: centos7-ansible-latest
2438
driver:
25-
image: ubuntu:12.04
26-
- name: ubuntu-14.04
39+
image: rndmh3ro/docker-centos7-ansible:latest
40+
platform: centos
41+
- name: oracle6-ansible-latest
2742
driver:
28-
image: ubuntu:14.04
29-
- name: ubuntu-16.04
43+
image: rndmh3ro/docker-oracle6-ansible:latest
44+
platform: centos
45+
- name: oracle7-ansible-latest
3046
driver:
31-
image: ubuntu:16.04
32-
- name: centos-6.6
47+
image: rndmh3ro/docker-oracle7-ansible:latest
48+
platform: centos
49+
- name: ubuntu1204-ansible-latest
3350
driver:
34-
image: centos:6.6
35-
- name: centos-6.7
51+
image: rndmh3ro/docker-ubuntu1204-ansible:latest
52+
platform: ubuntu
53+
- name: ubuntu1404-ansible-latest
3654
driver:
37-
image: centos:6.7
38-
- name: centos-7
55+
image: rndmh3ro/docker-ubuntu1404-ansible:latest
56+
platform: ubuntu
57+
- name: ubuntu1604-ansible-latest
3958
driver:
40-
image: centos:7
41-
privileged: true
42-
run_command: /usr/sbin/init
43-
- name: debian-7
59+
image: rndmh3ro/docker-ubuntu1604-ansible:latest
60+
platform: ubuntu
61+
- name: debian7-ansible-latest
4462
driver:
45-
image: debian:7
46-
- name: debian-8
63+
image: rndmh3ro/docker-debian7-ansible:latest
64+
platform: debian
65+
- name: debian8-ansible-latest
4766
driver:
48-
image: debian:8
67+
image: rndmh3ro/docker-debian8-ansible:latest
68+
platform: debian
69+
#- name: debian9-ansible-latest
70+
# driver:
71+
# image: rndmh3ro/docker-debian9-ansible:latest
72+
# platform: debian
4973

5074
verifier:
5175
name: inspec
5276
sudo: true
5377
inspec_tests:
54-
- https://github.com/dev-sec/tests-ssh-hardening
78+
- https://github.com/dev-sec/ssh-baseline
5579

5680
suites:
57-
- name: ssh-ansible_1.9
58-
provisioner:
59-
ansible_version: 1.9.4
60-
- name: ssh-ansible_latest
81+
- name: ssh

.travis.yml

Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,67 @@
11
---
2-
notifications:
3-
webhooks: https://galaxy.ansible.com/api/v1/notifications/
4-
language: python
5-
python: "2.7"
2+
services: docker
63

74
env:
8-
- ANSIBLE_VERSION=latest
9-
- ANSIBLE_VERSION=1.9.4
5+
- distro: centos6
6+
version: latest
7+
init: /sbin/init
8+
9+
- distro: centos7
10+
init: /usr/lib/systemd/systemd
11+
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
12+
version: latest
13+
14+
- distro: oracle6
15+
version: latest
16+
init: /sbin/init
17+
18+
- distro: oracle7
19+
init: /usr/lib/systemd/systemd
20+
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
21+
version: latest
22+
23+
- distro: ubuntu1604
24+
version: latest
25+
init: /lib/systemd/systemd
26+
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
27+
28+
- distro: ubuntu1404
29+
version: latest
30+
init: /sbin/init
31+
32+
- distro: ubuntu1204
33+
version: latest
34+
init: /sbin/init
35+
36+
- distro: debian7
37+
version: latest
38+
init: /sbin/init
39+
40+
- distro: debian8
41+
version: latest
42+
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
43+
init: /sbin/init
44+
45+
# - distro: debian9
46+
# version: latest
47+
# init: /lib/systemd/systemd
48+
# run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
49+
1050

1151
before_install:
12-
- sudo apt-get update -qq
13-
- sudo apt-get install -qq python-apt python-pycurl
14-
install:
15-
- if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install ansible; else pip install ansible==$ANSIBLE_VERSION; fi
16-
- echo -e 'localhost ansible_connection=local' > spec/inventory
17-
- echo -e '[defaults]\nroles_path = ../\nhostfile = ./spec/inventory' > ansible.cfg
52+
# Pull container
53+
- 'docker pull rndmh3ro/docker-${distro}-ansible:${version}'
1854

1955
script:
20-
- ansible-playbook --syntax-check spec/travis.yml
21-
- ansible-playbook --sudo -v --diff spec/travis.yml
22-
- ansible-playbook --sudo -v --diff spec/travis.yml --extra-vars "network_ipv6_enable=true ssh_allow_root_with_key=true ssh_client_password_login=true ssh_client_cbc_required=true ssh_server_weak_hmac=true ssh_client_weak_kex=true sftp_enabled=true"
56+
- container_id=$(mktemp)
57+
# Run container in detached state.
58+
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/ansible-ssh-hardening:ro ${run_opts} rndmh3ro/docker-${distro}-ansible:${version} "${init}" > "${container_id}"'
59+
60+
# Test role.
61+
- 'docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/ansible-ssh-hardening/default.yml'
62+
63+
# Verify role
64+
- 'inspec exec https://github.com/dev-sec/ssh-baseline/ -t docker://$(cat ${container_id})'
65+
66+
notifications:
67+
webhooks: https://galaxy.ansible.com/api/v1/notifications/

Gemfile

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@
22

33
source 'https://rubygems.org'
44

5-
group :test do
6-
gem 'rake'
7-
gem 'foodcritic', '~> 4.0'
8-
gem 'thor-foodcritic'
9-
gem 'coveralls', require: false
10-
end
11-
12-
group :development do
13-
gem 'guard'
14-
gem 'guard-rspec'
15-
gem 'guard-kitchen'
16-
end
17-
185
group :integration do
196
gem 'test-kitchen', '~> 1.0'
207
gem 'kitchen-ansible'
@@ -26,10 +13,6 @@ group :integration do
2613
gem 'kitchen-docker'
2714
end
2815

29-
group :openstack do
30-
gem 'kitchen-openstack'
31-
end
32-
3316
group :tools do
3417
gem 'github_changelog_generator', '~> 1'
3518
end

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Warning: This role disables root-login on the target server! Please make sure yo
1212

1313
## Requirements
1414

15-
* Ansible
15+
* Ansible > 2.2.1
1616

1717
## Role Variables
1818
| Name | Default Value | Description |
@@ -24,13 +24,13 @@ Warning: This role disables root-login on the target server! Please make sure yo
2424
|`ssh_server_weak_hmac` | false |true if weaker HMAC mechanisms are required. This is usually only necessary, if older M2M mechanism need to communicate with SSH, that don't have any of the configured secure HMACs enabled.|
2525
|`ssh_client_weak_kex` | false |true if weaker Key-Exchange (KEX) mechanisms are required. This is usually only necessary, if older M2M mechanism need to communicate with SSH, that don't have any of the configured secure KEXs enabled.|
2626
|`ssh_server_weak_kex` | false |true if weaker Key-Exchange (KEX) mechanisms are required. This is usually only necessary, if older M2M mechanism need to communicate with SSH, that don't have any of the configured secure KEXs enabled.|
27-
|`ssh_server_ports` | ['22'] |ports to which ssh-server should listen to|
28-
|`ssh_client_ports` | ['22'] |ports to which ssh-client should connect to|
27+
|`ssh_server_ports` | ['22'] |ports on which ssh-server should listen|
28+
|`ssh_client_port` | '22' |port to which ssh-client should connect|
2929
|`ssh_listen_to` | ['0.0.0.0'] |one or more ip addresses, to which ssh-server should listen to. Default is all adresseses, but should be configured to specific addresses for security reasons!|
3030
|`ssh_host_key_files` | ['/etc/ssh/ssh_host_rsa_key', '/etc/ssh/ssh_host_dsa_key', '/etc/ssh/ssh_host_ecdsa_key'] |Host keys to look for when starting sshd.|
3131
|`ssh_client_alive_interval` | 600 | specifies an interval for sending keepalive messages |
3232
|`ssh_client_alive_count` | 3 | defines how often keep-alive messages are sent |
33-
|`ssh_remote_hosts` | [] | one or more hosts, to which ssh-client can connect to. Default is empty, but should be configured for security reasons!|
33+
|`ssh_remote_hosts` | [] | one or more hosts and their custom options for the ssh-client. Default is empty. See examples in `defaults/main.yml`.|
3434
|`ssh_allow_root_with_key` | false | false to disable root login altogether. Set to true to allow root to login via key-based mechanism.|
3535
|`ssh_allow_tcp_forwarding` | false | false to disable TCP Forwarding. Set to true to allow TCP Forwarding.|
3636
|`ssh_allow_agent_forwarding` | false | false to disable Agent Forwarding. Set to true to allow Agent Forwarding.|
@@ -44,6 +44,8 @@ Warning: This role disables root-login on the target server! Please make sure yo
4444
|`sftp_enabled` | false | true to enable sftp configuration|
4545
|`sftp_chroot_dir` | /home/%u | change default sftp chroot location|
4646
|`ssh_client_roaming` | false | enable experimental client roaming|
47+
|`sshd_moduli_minimum` | 2048 | remove Diffie-Hellman parameters smaller than the defined size to mitigate logjam|
48+
|`ssh_challengeresponseauthentication` | false | Specifies whether challenge-response authentication is allowed (e.g. via PAM) |
4749

4850
## Example Playbook
4951

ansible.cfg

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# config file for ansible -- http://ansible.com/
2+
# ==============================================
3+
4+
# nearly all parameters can be overridden in ansible-playbook
5+
# or with command line flags. ansible will read ANSIBLE_CONFIG,
6+
# ansible.cfg in the current working directory, .ansible.cfg in
7+
# the home directory or /etc/ansible/ansible.cfg, whichever it
8+
# finds first
9+
10+
[defaults]
11+
ansible_managed = Ansible managed: {file} modified on %Y-%m-%d by {uid} on {host}
12+
13+
role_path = /vagrant
14+
scp_if_ssh = True

0 commit comments

Comments
 (0)