46 lines
1.2 KiB
YAML
46 lines
1.2 KiB
YAML
- name: OpenSSH Configuration Playbook
|
|
hosts: linux
|
|
remote_user: bhays
|
|
become: true
|
|
become_user: root
|
|
tasks:
|
|
- name: Update/install OpenSSH
|
|
ansible.builtin.apt:
|
|
name: openssh-server
|
|
state: latest
|
|
update_cache: true
|
|
- name: Add 'bhays' user
|
|
ansible.builtin.user:
|
|
name: bhays
|
|
groups: sudo,adm
|
|
append: true
|
|
shell: /bin/bash
|
|
comment: Benjamin Hays
|
|
- name: Update/install Sudo
|
|
ansible.builtin.apt:
|
|
name: sudo
|
|
state: latest
|
|
- name: Ensure .ssh user folder exists
|
|
ansible.builtin.file:
|
|
path: "/home/bhays/.ssh/"
|
|
owner: bhays
|
|
group: bhays
|
|
mode: "0770"
|
|
state: directory
|
|
- name: Copy public key
|
|
ansible.builtin.copy:
|
|
owner: bhays
|
|
mode: "0600"
|
|
src: ~/.ssh/authorized_keys
|
|
dest: /home/bhays/.ssh/authorized_keys
|
|
- name: Copy Secure Configuration File
|
|
ansible.builtin.copy:
|
|
owner: bhays
|
|
mode: "0600"
|
|
src: ../Configs/sshd_config
|
|
dest: /etc/ssh/sshd_config
|
|
- name: Restart OpenSSH
|
|
ansible.builtin.systemd:
|
|
name: sshd
|
|
state: restarted
|