48 lines
911 B
YAML
48 lines
911 B
YAML
- name: Install OpenSSH for Debian
|
|
package:
|
|
name: openssh-server
|
|
become: true
|
|
when: ansible_os_family == 'Debian'
|
|
|
|
- name: Install OpenSSH for Arch
|
|
package:
|
|
name: openssh
|
|
become: true
|
|
when: ansible_os_family == 'Archlinux'
|
|
|
|
- name: Define context
|
|
set_fact:
|
|
user: jake
|
|
enable_root: false
|
|
|
|
- name: SSH config
|
|
template:
|
|
src: files/sshd_config
|
|
dest: /etc/ssh/sshd_config
|
|
validate: /usr/sbin/sshd -t -f %s
|
|
backup: yes
|
|
mode: 0644
|
|
become: true
|
|
register: sshd_config
|
|
|
|
- name: Set up authorized keys
|
|
ansible.posix.authorized_key:
|
|
user: "{{ user }}"
|
|
state: present
|
|
key: "{{ lookup('file', item) }}"
|
|
loop:
|
|
- ssh-keys/ps.pub
|
|
- ssh-keys/mobile.pub
|
|
|
|
- name: Enable SSH
|
|
service:
|
|
name: sshd
|
|
enabled: true
|
|
become: true
|
|
|
|
- name: Restart SSH Daemon
|
|
service:
|
|
name: sshd
|
|
state: reloaded
|
|
when: sshd_config.changed
|
|
become: true
|