Skip to content

Commit

Permalink
[OCRVS-6350] Disable root (#849)
Browse files Browse the repository at this point in the history
* disable root login completely

* stop users from using 'su'

* only disable root login if ansible user being used is not root
  • Loading branch information
rikukissa authored Jan 22, 2024
1 parent ce29cb2 commit 8608fb5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions infrastructure/server-setup/tasks/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
state: '{{ item.state }}'
with_items: '{{ users }}'

- name: Grant passwordless sudo to the users
- name: Grant passwordless sudo to the users, but prevent usage of 'su'
ansible.builtin.lineinfile:
path: /etc/sudoers.d/{{ item.name }}
line: '{{ item.name }} ALL=(ALL) NOPASSWD:ALL'
line: '{{ item.name }} ALL=(ALL) NOPASSWD:ALL, !/usr/bin/su'
validate: 'visudo -cf %s'
create: yes
become: yes
Expand Down Expand Up @@ -122,6 +122,12 @@
state: present
when: ansible_user != "root"

- name: Disable root account login completely
ansible.builtin.command:
cmd: passwd -l root
become: yes
when: ansible_user != "root"

- name: Enable KbdInteractiveAuthentication in SSHD Config
lineinfile:
path: /etc/ssh/sshd_config
Expand Down

0 comments on commit 8608fb5

Please sign in to comment.