Created
December 24, 2018 05:23
-
-
Save WhiteyDude/7bae7b2a255d5fc05c9e47f669d5491f to your computer and use it in GitHub Desktop.
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
--- | |
- hosts: all | |
become: true | |
become_user: "root" | |
become_method: sudo | |
tasks: | |
- name: Make .ssh directory | |
file: | |
path: "/root/.ssh" | |
state: directory | |
- name: Delete existing authorized_keys file | |
file: | |
state: absent | |
path: "/root/.ssh/authorized_keys" | |
- name: Create authorized_keys file | |
file: | |
path: "/root/.ssh/authorized_keys" | |
state: touch | |
- name: Put pubkey - User 1 | |
lineinfile: | |
path: "/root/.ssh/authorized_keys" | |
line: "ssh-rsa Keyhere" | |
- name: Put pubkey - User 2 | |
lineinfile: | |
path: "/root/.ssh/authorized_keys" | |
line: "ssh-rsa Keyhere" | |
- name: Permit root login | |
lineinfile: | |
path: /etc/ssh/sshd_config | |
regexp: '^PermitRootLogin' | |
line: 'PermitRootLogin Yes' | |
- name: Restart SSH | |
service: name=sshd state=restarted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment