You've already forked ansible-linux-infra
initial commit
This commit is contained in:
5
roles/ssh_hardening/handlers/main.yml
Normal file
5
roles/ssh_hardening/handlers/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: restart sshd
|
||||
ansible.builtin.systemd:
|
||||
name: sshd
|
||||
state: restarted
|
||||
27
roles/ssh_hardening/tasks/main.yml
Normal file
27
roles/ssh_hardening/tasks/main.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
- name: Deploy sshd_config
|
||||
ansible.builtin.template:
|
||||
src: sshd_config.j2
|
||||
dest: /etc/ssh/sshd_config
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0600"
|
||||
validate: "/usr/sbin/sshd -t -f %s"
|
||||
notify: restart sshd
|
||||
tags: [ssh_hardening]
|
||||
|
||||
- name: Create sshd_config.d drop-in directory for future exceptions
|
||||
ansible.builtin.file:
|
||||
path: /etc/ssh/sshd_config.d
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
tags: [ssh_hardening]
|
||||
|
||||
- name: Enable and start sshd
|
||||
ansible.builtin.systemd:
|
||||
name: sshd
|
||||
enabled: true
|
||||
state: started
|
||||
tags: [ssh_hardening]
|
||||
34
roles/ssh_hardening/templates/sshd_config.j2
Normal file
34
roles/ssh_hardening/templates/sshd_config.j2
Normal file
@@ -0,0 +1,34 @@
|
||||
# {{ ansible_managed }}
|
||||
Port {{ ssh_port }}
|
||||
Protocol 2
|
||||
|
||||
PermitRootLogin no
|
||||
PasswordAuthentication no
|
||||
PubkeyAuthentication yes
|
||||
ChallengeResponseAuthentication no
|
||||
KbdInteractiveAuthentication no
|
||||
UsePAM yes
|
||||
MaxAuthTries {{ ssh_max_auth_tries }}
|
||||
AllowGroups {{ ssh_allow_groups }}
|
||||
|
||||
ClientAliveInterval {{ ssh_client_alive_interval }}
|
||||
ClientAliveCountMax {{ ssh_client_alive_count_max }}
|
||||
LoginGraceTime 30
|
||||
MaxSessions 4
|
||||
MaxStartups 10:30:60
|
||||
|
||||
X11Forwarding no
|
||||
AllowTcpForwarding no
|
||||
AllowAgentForwarding no
|
||||
PermitTunnel no
|
||||
GatewayPorts no
|
||||
|
||||
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
|
||||
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com
|
||||
KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,diffie-hellman-group16-sha512
|
||||
|
||||
Banner /etc/issue.net
|
||||
LogLevel VERBOSE
|
||||
SyslogFacility AUTHPRIV
|
||||
|
||||
Include /etc/ssh/sshd_config.d/*.conf
|
||||
Reference in New Issue
Block a user