Skip to content

Instantly share code, notes, and snippets.

@WhiteyDude
Created December 24, 2018 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WhiteyDude/7bae7b2a255d5fc05c9e47f669d5491f to your computer and use it in GitHub Desktop.
Save WhiteyDude/7bae7b2a255d5fc05c9e47f669d5491f to your computer and use it in GitHub Desktop.
---
- 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