adding ssh role
This commit is contained in:
5
roles/ssh/handlers/main.yml
Normal file
5
roles/ssh/handlers/main.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- name: restart ssh
|
||||||
|
service:
|
||||||
|
name: ssh
|
||||||
|
state: restarted
|
||||||
19
roles/ssh/tasks/main.yml
Normal file
19
roles/ssh/tasks/main.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
- name: Configure SSH access
|
||||||
|
tags: [ssh, server]
|
||||||
|
become: true
|
||||||
|
block:
|
||||||
|
- name: Remove any PermitRootLogin instruction
|
||||||
|
lineinfile:
|
||||||
|
dest: /etc/ssh/sshd_config
|
||||||
|
regexp: "^PermitRootLogin"
|
||||||
|
state: absent
|
||||||
|
notify: restart ssh
|
||||||
|
|
||||||
|
- name: Disable SSH root login
|
||||||
|
lineinfile:
|
||||||
|
dest: /etc/ssh/sshd_config
|
||||||
|
regexp: "^PermitRootLogin"
|
||||||
|
line: "PermitRootLogin prohibit-password"
|
||||||
|
state: present
|
||||||
|
notify: restart ssh
|
||||||
Reference in New Issue
Block a user