a few things
This commit is contained in:
parent
04fce4fcae
commit
8766af831c
3 changed files with 10 additions and 3 deletions
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
- name: Copy current user's authorized_keys to new user
|
||||
copy:
|
||||
src: "/home/{{ ansible_user }}/.ssh/authorized_keys"
|
||||
src: "{{ (ansible_user == 'root') | ternary('/root/.ssh/authorized_keys', '/home/' + ansible_user + '/.ssh/authorized_keys') }}"
|
||||
dest: "/home/{{ new_user }}/.ssh/authorized_keys"
|
||||
owner: "{{ new_user }}"
|
||||
group: "{{ new_user }}"
|
||||
|
|
@ -58,8 +58,15 @@
|
|||
line: "PasswordAuthentication no",
|
||||
}
|
||||
|
||||
- name: Ensure PasswordAuthentication is set to no in cloud-init config
|
||||
lineinfile:
|
||||
path: /etc/ssh/sshd_config.d/50-cloud-init.conf
|
||||
regexp: "^PasswordAuthentication"
|
||||
line: "PasswordAuthentication no"
|
||||
create: yes
|
||||
backup: yes
|
||||
|
||||
- name: Restart SSH
|
||||
service:
|
||||
name: ssh
|
||||
state: restarted
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue