Allow passwordless sudo for ssh login user

This commit is contained in:
2020-01-04 11:39:24 +01:00
parent 4c979b88f5
commit 9c2c274d1b
2 changed files with 10 additions and 2 deletions
+9 -2
View File
@@ -26,6 +26,13 @@
append: yes append: yes
groups: groups:
- sudo - sudo
- name: allow passwordless sudo for new user
template:
src: etc/sudoers.d/ssh_user.j2
dest: /etc/sudoers.d/{{ ssh_user }}
owner: root
group: root
mode: 0440
- name: add authorized key to SSH login user - name: add authorized key to SSH login user
authorized_key: authorized_key:
key: "{{ item }}" key: "{{ item }}"
@@ -41,13 +48,13 @@
path: /etc/ssh/sshd_config path: /etc/ssh/sshd_config
line: 'PermitRootLogin no' line: 'PermitRootLogin no'
state: present state: present
insertafter: EOF insertafter: EOF
- name: disable password authentication - name: disable password authentication
lineinfile: lineinfile:
path: /etc/ssh/sshd_config path: /etc/ssh/sshd_config
line: 'PasswordAuthentication no' line: 'PasswordAuthentication no'
state: present state: present
insertafter: EOF insertafter: EOF
- name: set modern host key - name: set modern host key
lineinfile: lineinfile:
dest: /etc/ssh/sshd_config dest: /etc/ssh/sshd_config
+1
View File
@@ -0,0 +1 @@
{{ ssh_user }} ALL=(ALL) NOPASSWD:ALL