-
Notifications
You must be signed in to change notification settings - Fork 0
/
lockdown.yml
40 lines (35 loc) · 1005 Bytes
/
lockdown.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
- name: Add deploy user and disable root user
hosts: all
vars:
remote_user: root
tasks:
- name: Add a new user named deploy
user: name=deploy
- name: Add deploy user to the sudoers
copy:
dest: "/etc/sudoers.d/deploy"
content: "deploy ALL=(ALL) NOPASSWD: ALL"
- name: Deploy your SSH Key
authorized_key: user=deploy
key="{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
state=present
- name: Disable Password Authentication
lineinfile: dest=/etc/ssh/sshd_config
regexp='^PasswordAuthentication'
line="PasswordAuthentication no"
state=present
backup=yes
notify:
- restart ssh
- name: Disable Root Login
lineinfile: dest=/etc/ssh/sshd_config
regexp='^PermitRootLogin'
line="PermitRootLogin no"
state=present
backup=yes
notify:
- restart ssh
handlers:
- name: restart ssh
service: name=ssh
state=restarted