a few things

This commit is contained in:
counterweight 2025-07-09 00:32:51 +02:00
parent 04fce4fcae
commit 8766af831c
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
3 changed files with 10 additions and 3 deletions

View file

@ -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