sshd: Move ssh deamon configuration to own role
This commit is contained in:
parent
c99efeab61
commit
0172750ca1
3 changed files with 66 additions and 44 deletions
|
@ -25,50 +25,6 @@
|
|||
owner: root
|
||||
group: "{{ ansible_wheel }}"
|
||||
|
||||
# use mozilla recommended settings (only prefer aes256 over chacha20)
|
||||
# https://infosec.mozilla.org/guidelines/openssh.html
|
||||
- name: tighten sshd kex algorithms
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
line: "KexAlgorithms curve25519-sha256@libssh.org,\
|
||||
diffie-hellman-group-exchange-sha256"
|
||||
regexp: "^KexAlgorithms .*"
|
||||
notify: restart sshd
|
||||
- name: tighten sshd ciphers
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
line: "Ciphers aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,\
|
||||
aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr"
|
||||
regexp: "^Ciphers .*"
|
||||
notify: restart sshd
|
||||
- name: tighten sshd macs
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
line: "MACs hmac-sha2-512-etm@openssh.com,\
|
||||
hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,\
|
||||
hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com"
|
||||
regexp: "^MACs .*"
|
||||
notify: restart sshd
|
||||
|
||||
- name: disable ecdsa key from sshd
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
line: "#HostKey /etc/ssh/ssh_host_ecdsa_key"
|
||||
regexp: "^#?HostKey /etc/ssh/ssh_host_ecdsa_key"
|
||||
notify: restart sshd
|
||||
- name: disable rsa key from sshd
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
line: "#HostKey /etc/ssh/ssh_host_rsa_key"
|
||||
regexp: "^#?HostKey /etc/ssh/ssh_host_rsa_key"
|
||||
notify: restart sshd
|
||||
- name: enable ed25519 key from sshd
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
line: "HostKey /etc/ssh/ssh_host_ed25519_key"
|
||||
regexp: "^#?HostKey /etc/ssh/ssh_host_ed25519_key"
|
||||
notify: restart sshd
|
||||
|
||||
- name: install basic roles
|
||||
include_role:
|
||||
name: "{{ role }}"
|
||||
|
@ -76,5 +32,6 @@
|
|||
- network
|
||||
- pki
|
||||
- psacct
|
||||
- sshd
|
||||
loop_control:
|
||||
loop_var: role
|
||||
|
|
5
roles/sshd/handlers/main.yml
Normal file
5
roles/sshd/handlers/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: restart sshd
|
||||
service:
|
||||
name: sshd
|
||||
state: restarted
|
60
roles/sshd/tasks/main.yml
Normal file
60
roles/sshd/tasks/main.yml
Normal file
|
@ -0,0 +1,60 @@
|
|||
---
|
||||
|
||||
# based on mozilla recommended settings
|
||||
# https://infosec.mozilla.org/guidelines/openssh.html
|
||||
#
|
||||
# * prefer aes over chacha for hardware acceleration
|
||||
# * use only ed25519 host key
|
||||
#
|
||||
|
||||
- name: tighten ssh kex algorithm
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
line: "KexAlgorithms curve25519-sha256@libssh.org,\
|
||||
diffie-hellman-group-exchange-sha256"
|
||||
regexp: "^KexAlgorithms .*"
|
||||
validate: "sshd -t -f %s"
|
||||
notify: restart sshd
|
||||
|
||||
- name: tighten sshd ciphers
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
line: "Ciphers aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,\
|
||||
aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr"
|
||||
regexp: "^Ciphers .*"
|
||||
validate: "sshd -t -f %s"
|
||||
notify: restart sshd
|
||||
|
||||
- name: tighten sshd macs
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
line: "MACs hmac-sha2-512-etm@openssh.com,\
|
||||
hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,\
|
||||
hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com"
|
||||
regexp: "^MACs .*"
|
||||
validate: "sshd -t -f %s"
|
||||
notify: restart sshd
|
||||
|
||||
- name: disable ecdsa key from sshd
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
line: "#HostKey /etc/ssh/ssh_host_ecdsa_key"
|
||||
regexp: "^#?HostKey /etc/ssh/ssh_host_ecdsa_key"
|
||||
validate: "sshd -t -f %s"
|
||||
notify: restart sshd
|
||||
|
||||
- name: disable rsa key from sshd
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
line: "#HostKey /etc/ssh/ssh_host_rsa_key"
|
||||
regexp: "^#?HostKey /etc/ssh/ssh_host_rsa_key"
|
||||
validate: "sshd -t -f %s"
|
||||
notify: restart sshd
|
||||
|
||||
- name: enable ed25519 key from sshd
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config
|
||||
line: "HostKey /etc/ssh/ssh_host_ed25519_key"
|
||||
regexp: "^#?HostKey /etc/ssh/ssh_host_ed25519_key"
|
||||
validate: "sshd -t -f %s"
|
||||
notify: restart sshd
|
Loading…
Add table
Reference in a new issue