From: Oleg Broytman Date: Wed, 24 Jul 2019 16:16:43 +0000 (+0300) Subject: Feat(init-system2): Setup `sshd` X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=4d94f52fdb488f7b7b8328212824df69c66424d6;p=ansible.git Feat(init-system2): Setup `sshd` --- diff --git a/playbooks/debian/init-system2.yml b/playbooks/debian/init-system2.yml index 1db16fd..866cbf2 100644 --- a/playbooks/debian/init-system2.yml +++ b/playbooks/debian/init-system2.yml @@ -6,3 +6,4 @@ - root - firewall - logcheck + - sshd diff --git a/playbooks/debian/roles/sshd/README.txt b/playbooks/debian/roles/sshd/README.txt new file mode 100644 index 0000000..f1ea9db --- /dev/null +++ b/playbooks/debian/roles/sshd/README.txt @@ -0,0 +1 @@ +Init new Debian system: configure sshd. diff --git a/playbooks/debian/roles/sshd/handlers/main.yml b/playbooks/debian/roles/sshd/handlers/main.yml new file mode 100644 index 0000000..4d75e71 --- /dev/null +++ b/playbooks/debian/roles/sshd/handlers/main.yml @@ -0,0 +1,4 @@ +- name: Reload sshd + service: + name: ssh + state: reloaded diff --git a/playbooks/debian/roles/sshd/tasks/main.yml b/playbooks/debian/roles/sshd/tasks/main.yml new file mode 100644 index 0000000..9f76108 --- /dev/null +++ b/playbooks/debian/roles/sshd/tasks/main.yml @@ -0,0 +1,24 @@ +- name: Check sshd + shell: "grep -c '^PermitRootLogin' /etc/ssh/sshd_config || :" + register: sshd + changed_when: sshd.stdout == "0" + +- debug: + msg: "sshd has already been configured" + when: sshd.stdout != "0" + +- name: Configure sshd + become: true + lineinfile: + path: /etc/ssh/sshd_config + regexp: "^{{ item }}" + line: "{{ item }}" + loop: [ + 'PermitRootLogin prohibit-password', + '# See http://www.openssh.com/txt/cbc.adv', + 'Ciphers aes128-ctr,aes256-ctr,aes128-cbc,aes256-cbc', + 'PermitTunnel point-to-point', + + ] + notify: Reload sshd + when: sshd.stdout == "0"