sshd: ansible-lint fixes
This commit is contained in:
parent
bcbbaece64
commit
8cb151b985
2 changed files with 29 additions and 30 deletions
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- name: restart sshd
|
- name: Restart sshd
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: sshd
|
name: sshd
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
---
|
---
|
||||||
|
- name: Disable AllowAgentForwarding
|
||||||
- name: disable AllowAgentForwarding
|
ansible.builtin.lineinfile:
|
||||||
lineinfile:
|
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
regexp: '^#?AllowAgentForwarding'
|
regexp: '^#?AllowAgentForwarding'
|
||||||
line: 'AllowAgentForwarding no'
|
line: 'AllowAgentForwarding no'
|
||||||
validate: "sshd -t -f %s"
|
validate: "sshd -t -f %s"
|
||||||
notify: restart sshd
|
notify: Restart sshd
|
||||||
|
|
||||||
- name: disable ChallengeResponseAuthentication
|
- name: Disable ChallengeResponseAuthentication
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
regexp: '^#?ChallengeResponseAuthentication'
|
regexp: '^#?ChallengeResponseAuthentication'
|
||||||
line: 'ChallengeResponseAuthentication no'
|
line: 'ChallengeResponseAuthentication no'
|
||||||
validate: "sshd -t -f %s"
|
validate: "sshd -t -f %s"
|
||||||
notify: restart sshd
|
notify: Restart sshd
|
||||||
|
|
||||||
# based on mozilla recommended settings
|
# based on mozilla recommended settings
|
||||||
# https://infosec.mozilla.org/guidelines/openssh.html
|
# https://infosec.mozilla.org/guidelines/openssh.html
|
||||||
|
@ -22,64 +21,64 @@
|
||||||
# * prefer aes over chacha for hardware acceleration
|
# * prefer aes over chacha for hardware acceleration
|
||||||
# * use only ed25519 host key
|
# * use only ed25519 host key
|
||||||
#
|
#
|
||||||
- name: disable default crypto policy
|
- name: Disable default crypto policy
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/sysconfig/sshd
|
path: /etc/sysconfig/sshd
|
||||||
regexp: '^(#\s+)?CRYPTO_POLICY='
|
regexp: '^(#\s+)?CRYPTO_POLICY='
|
||||||
line: "CRYPTO_POLICY="
|
line: "CRYPTO_POLICY="
|
||||||
notify: restart sshd
|
notify: Restart sshd
|
||||||
when:
|
when:
|
||||||
- ansible_distribution == "CentOS"
|
- ansible_distribution == "CentOS"
|
||||||
- ansible_distribution_version is version_compare("8", ">=")
|
- ansible_distribution_version is version_compare("8", ">=")
|
||||||
|
|
||||||
- name: tighten ssh kex algorithm
|
- name: Tighten ssh kex algorithm
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
line: "KexAlgorithms curve25519-sha256@libssh.org,\
|
line: "KexAlgorithms curve25519-sha256@libssh.org,\
|
||||||
diffie-hellman-group-exchange-sha256"
|
diffie-hellman-group-exchange-sha256"
|
||||||
regexp: "^KexAlgorithms .*"
|
regexp: "^KexAlgorithms .*"
|
||||||
validate: "sshd -t -f %s"
|
validate: "sshd -t -f %s"
|
||||||
notify: restart sshd
|
notify: Restart sshd
|
||||||
|
|
||||||
- name: tighten sshd ciphers
|
- name: Tighten sshd ciphers
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
line: "Ciphers aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,\
|
line: "Ciphers aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,\
|
||||||
aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr"
|
aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr"
|
||||||
regexp: "^Ciphers .*"
|
regexp: "^Ciphers .*"
|
||||||
validate: "sshd -t -f %s"
|
validate: "sshd -t -f %s"
|
||||||
notify: restart sshd
|
notify: Restart sshd
|
||||||
|
|
||||||
- name: tighten sshd macs
|
- name: Tighten sshd macs
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
line: "MACs hmac-sha2-512-etm@openssh.com,\
|
line: "MACs hmac-sha2-512-etm@openssh.com,\
|
||||||
hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,\
|
hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,\
|
||||||
hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com"
|
hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com"
|
||||||
regexp: "^MACs .*"
|
regexp: "^MACs .*"
|
||||||
validate: "sshd -t -f %s"
|
validate: "sshd -t -f %s"
|
||||||
notify: restart sshd
|
notify: Restart sshd
|
||||||
|
|
||||||
- name: disable ecdsa key from sshd
|
- name: Disable ECDSA key from sshd
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
line: "#HostKey /etc/ssh/ssh_host_ecdsa_key"
|
line: "#HostKey /etc/ssh/ssh_host_ecdsa_key"
|
||||||
regexp: "^#?HostKey /etc/ssh/ssh_host_ecdsa_key"
|
regexp: "^#?HostKey /etc/ssh/ssh_host_ecdsa_key"
|
||||||
validate: "sshd -t -f %s"
|
validate: "sshd -t -f %s"
|
||||||
notify: restart sshd
|
notify: Restart sshd
|
||||||
|
|
||||||
- name: disable rsa key from sshd
|
- name: Disable RSA key from sshd
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
line: "#HostKey /etc/ssh/ssh_host_rsa_key"
|
line: "#HostKey /etc/ssh/ssh_host_rsa_key"
|
||||||
regexp: "^#?HostKey /etc/ssh/ssh_host_rsa_key"
|
regexp: "^#?HostKey /etc/ssh/ssh_host_rsa_key"
|
||||||
validate: "sshd -t -f %s"
|
validate: "sshd -t -f %s"
|
||||||
notify: restart sshd
|
notify: Restart sshd
|
||||||
|
|
||||||
- name: enable ed25519 key from sshd
|
- name: Enable ed25519 key from sshd
|
||||||
lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
line: "HostKey /etc/ssh/ssh_host_ed25519_key"
|
line: "HostKey /etc/ssh/ssh_host_ed25519_key"
|
||||||
regexp: "^#?HostKey /etc/ssh/ssh_host_ed25519_key"
|
regexp: "^#?HostKey /etc/ssh/ssh_host_ed25519_key"
|
||||||
validate: "sshd -t -f %s"
|
validate: "sshd -t -f %s"
|
||||||
notify: restart sshd
|
notify: Restart sshd
|
||||||
|
|
Loading…
Add table
Reference in a new issue