Allow passwordless sudo for ssh login user
This commit is contained in:
+9
-2
@@ -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
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
{{ ssh_user }} ALL=(ALL) NOPASSWD:ALL
|
||||||
Reference in New Issue
Block a user