homeserver/playbooks/on-off/delete_ssh.yml

27 lines
733 B
YAML
Raw Normal View History

---
- hosts: all
tasks:
- name: delete /home/mg/.ssh/authorized_keys
become: yes
ansible.builtin.file:
name: /home/mg/.ssh/authorized_keys
state: absent
- name: delete /home/ansible-user/.ssh/authorized_keys
become: yes
ansible.builtin.file:
name: /home/ansible-user/.ssh/authorized_keys
state: absent
- name: prohibit ssh login with password
become: yes
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
regexp: 'PasswordAuthentication no'
line: 'PasswordAuthentication yes'
state: present
- name: restart_sshd
become: yes
systemd:
name: sshd
enabled: yes
state: restarted