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#139 from dev-sec/macs_kex_ciphers
Macs kex ciphers
- Loading branch information
Showing
8 changed files
with
192 additions
and
149 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
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,62 @@ | ||
--- | ||
- name: wrapper playbook for kitchen testing "ansible-ssh-hardening" with custom settings | ||
hosts: localhost | ||
pre_tasks: | ||
- package: name="{{item}}" state=installed | ||
with_items: | ||
- "openssh-clients" | ||
- "openssh-server" | ||
ignore_errors: true | ||
- apt: name="{{item}}" state=installed update_cache=true | ||
with_items: | ||
- "openssh-client" | ||
- "openssh-server" | ||
ignore_errors: true | ||
- file: path="/var/run/sshd" state=directory | ||
- name: create ssh host keys | ||
command: "ssh-keygen -A" | ||
when: not ((ansible_os_family in ['Oracle Linux', 'RedHat']) and ansible_distribution_major_version < '7') | ||
|
||
roles: | ||
- ansible-ssh-hardening | ||
vars: | ||
network_ipv6_enable: true | ||
ssh_allow_root_with_key: true | ||
ssh_allow_tcp_forwarding: true | ||
ssh_gateway_ports: true | ||
ssh_allow_agent_forwarding: true | ||
ssh_server_permit_environment_vars: ['PWD','HTTP_PROXY'] | ||
ssh_client_alive_interval: 100 | ||
ssh_client_alive_count: 10 | ||
ssh_client_password_login: true | ||
ssh_client_cbc_required: true | ||
ssh_client_weak_kex: true | ||
ssh_challengeresponseauthentication: true | ||
ssh_compression: true | ||
ssh_allow_users: 'root kitchen vagrant' | ||
ssh_allow_groups: 'root kitchen vagrant' | ||
ssh_deny_users: 'foo bar' | ||
ssh_deny_groups: 'foo bar' | ||
ssh_authorized_keys_file: '/etc/ssh/authorized_keys/%u' | ||
ssh_max_auth_retries: 10 | ||
ssh_permit_tunnel: true | ||
ssh_print_motd: true | ||
ssh_print_last_log: true | ||
ssh_banner: true | ||
ssh_server_password_login: true | ||
ssh_server_weak_hmac: true | ||
sftp_enabled: true | ||
ssh_server_enabled: false | ||
ssh_server_match_group: | ||
- group: 'root' | ||
rules: 'AllowTcpForwarding yes' | ||
ssh_server_match_user: | ||
- user: 'root' | ||
rules: 'AllowTcpForwarding yes' | ||
ssh_remote_hosts: | ||
- names: ['example.com', 'example2.com'] | ||
options: ['Port 2222', 'ForwardAgent yes'] | ||
- names: ['example3.com'] | ||
options: ['StrictHostKeyChecking no'] | ||
ssh_use_dns: true | ||
ssh_use_pam: true |
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,98 @@ | ||
--- | ||
|
||
- name: set hostkeys according to openssh-version | ||
set_fact: | ||
ssh_host_key_files: ['/etc/ssh/ssh_host_rsa_key', '/etc/ssh/ssh_host_ecdsa_key', '/etc/ssh/ssh_host_ed25519_key'] | ||
when: sshd_version.stdout >= '6.3' and not ssh_host_key_files | ||
|
||
- name: set hostkeys according to openssh-version | ||
set_fact: | ||
ssh_host_key_files: ['/etc/ssh/ssh_host_rsa_key', '/etc/ssh/ssh_host_ecdsa_key'] | ||
when: sshd_version.stdout >= '6.0' and not ssh_host_key_files | ||
|
||
- name: set hostkeys according to openssh-version | ||
set_fact: | ||
ssh_host_key_files: ['/etc/ssh/ssh_host_rsa_key'] | ||
when: sshd_version.stdout >= '5.3' and not ssh_host_key_files | ||
|
||
### | ||
|
||
- name: set weak macs according to openssh-version if openssh >= 7.6 | ||
set_fact: | ||
ssh_macs: "{{ssh_macs_76_default}}" | ||
when: sshd_version.stdout >= '7.6' and not ssh_macs | ||
|
||
- name: set weak macs according to openssh-version if openssh >= 6.6 | ||
set_fact: | ||
ssh_macs: "{{ssh_macs_66_weak}}" | ||
when: sshd_version.stdout >= '6.6' and ssh_server_weak_hmac and not ssh_macs | ||
|
||
- name: set macs according to openssh-version if openssh >= 6.6 | ||
set_fact: | ||
ssh_macs: "{{ssh_macs_66_default}}" | ||
when: sshd_version.stdout >= '6.6' and not ssh_macs | ||
|
||
- name: set weak macs according to openssh-version | ||
set_fact: | ||
ssh_macs: "{{ssh_macs_59_weak}}" | ||
when: sshd_version.stdout >= '5.9' and ssh_server_weak_hmac and not ssh_macs | ||
|
||
- name: set macs according to openssh-version | ||
set_fact: | ||
ssh_macs: "{{ssh_macs_59_default}}" | ||
when: sshd_version.stdout >= '5.9' and not ssh_macs | ||
|
||
- name: set macs according to openssh-version | ||
set_fact: | ||
ssh_macs: "{{ssh_macs_53_default}}" | ||
when: sshd_version.stdout >= '5.3' and not ssh_macs | ||
|
||
- name: set macs according to openssh-version | ||
set_fact: | ||
ssh_macs: "{{ssh_macs_53_default}}" | ||
when: sshd_version.stdout >= '5.3' and not ssh_macs | ||
|
||
### | ||
|
||
- name: set weak ciphers according to openssh-version if openssh >= 6.6 | ||
set_fact: | ||
ssh_ciphers: "{{ssh_ciphers_66_weak}}" | ||
when: sshd_version.stdout >= '6.6' and ssh_server_cbc_required and not ssh_ciphers | ||
|
||
- name: set ciphers according to openssh-version if openssh >= 6.6 | ||
set_fact: | ||
ssh_ciphers: "{{ssh_ciphers_66_default}}" | ||
when: sshd_version.stdout >= '6.6' and not ssh_ciphers | ||
|
||
- name: set weak ciphers according to openssh-version | ||
set_fact: | ||
ssh_ciphers: "{{ssh_ciphers_53_weak}}" | ||
when: sshd_version.stdout >= '5.3' and ssh_server_cbc_required and not ssh_ciphers | ||
|
||
- name: set ciphers according to openssh-version | ||
set_fact: | ||
ssh_ciphers: "{{ssh_ciphers_53_default}}" | ||
when: sshd_version.stdout >= '5.3' and not ssh_ciphers | ||
|
||
### | ||
|
||
- name: set weak kex according to openssh-version if openssh >= 6.6 | ||
set_fact: | ||
ssh_kex: "{{ssh_kex_66_weak}}" | ||
when: sshd_version.stdout >= '6.6' and ssh_server_weak_hmac and not ssh_kex | ||
|
||
- name: set kex according to openssh-version if openssh >= 6.6 | ||
set_fact: | ||
ssh_kex: "{{ssh_kex_66_default}}" | ||
when: sshd_version.stdout >= '6.6' and not ssh_kex | ||
|
||
- name: set weak kex according to openssh-version | ||
set_fact: | ||
ssh_kex: "{{ssh_kex_59_weak}}" | ||
when: sshd_version.stdout >= '5.9' and ssh_server_weak_hmac and not ssh_kex | ||
|
||
- name: set kex according to openssh-version | ||
set_fact: | ||
ssh_kex: "{{ssh_kex_59_default}}" | ||
when: sshd_version.stdout >= '5.9' and not ssh_kex | ||
|
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.