Last active
August 21, 2020 23:50
-
-
Save alanreynosov/f0ac2cf24becc1973502cd1e39a67d95 to your computer and use it in GitHub Desktop.
ansible playbook to disable password authentication in a raspberry pi with raspberry OS or any debian based distro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Log in as pi user to disable root | |
hosts: nodes | |
user: "pi" | |
gather_facts: false | |
become: yes | |
tasks: | |
- name: Disable root login over SSH | |
lineinfile: dest=/etc/ssh/sshd_config regexp="^PermitRootLogin" line="PermitRootLogin no" state=present | |
notify: | |
- restart sshd | |
- name: Disable password login | |
lineinfile: dest=/etc/ssh/sshd_config regexp="^PasswordAuthentication" line="PasswordAuthentication no" state=present | |
notify: | |
- restart sshd | |
handlers: | |
- name: restart sshd | |
service: | |
name: sshd | |
state: restarted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ansible playbook to disable password authentication in a raspberry pi with raspberry OS or any debian based distro