2020-04-26 12:16:18 +01:00
|
|
|
- name: Install OpenSSH for Debian
|
2020-04-26 11:25:01 +01:00
|
|
|
package:
|
2019-12-08 16:03:13 +00:00
|
|
|
name: openssh-server
|
|
|
|
become: true
|
2020-04-26 12:16:18 +01:00
|
|
|
when: ansible_os_family == 'Debian'
|
|
|
|
|
|
|
|
- name: Install OpenSSH for Arch
|
|
|
|
package:
|
|
|
|
name: openssh
|
|
|
|
become: true
|
2020-08-19 17:59:56 +01:00
|
|
|
when: ansible_os_family == 'Archlinux'
|
2019-12-08 16:03:13 +00:00
|
|
|
|
2019-12-08 15:55:19 +00:00
|
|
|
- name: Define context
|
|
|
|
set_fact:
|
|
|
|
user: jake
|
2020-01-26 18:10:07 +00:00
|
|
|
enable_root: false
|
2019-12-08 15:55:19 +00:00
|
|
|
|
|
|
|
- name: SSH config
|
|
|
|
template:
|
2020-01-28 20:39:42 +00:00
|
|
|
src: files/sshd_config
|
2019-12-08 15:55:19 +00:00
|
|
|
dest: /etc/ssh/sshd_config
|
|
|
|
validate: /usr/sbin/sshd -t -f %s
|
2022-01-11 20:51:12 +00:00
|
|
|
backup: true
|
2020-09-26 17:53:47 +01:00
|
|
|
mode: 0644
|
2019-12-08 15:55:19 +00:00
|
|
|
become: true
|
|
|
|
register: sshd_config
|
|
|
|
|
2020-05-23 11:04:50 +01:00
|
|
|
- name: Set up authorized keys
|
2021-02-07 13:02:14 +00:00
|
|
|
ansible.posix.authorized_key:
|
2020-05-23 11:04:50 +01:00
|
|
|
user: "{{ user }}"
|
|
|
|
state: present
|
2020-05-23 11:18:48 +01:00
|
|
|
key: "{{ lookup('file', item) }}"
|
|
|
|
loop:
|
2020-05-23 11:04:50 +01:00
|
|
|
- ssh-keys/ps.pub
|
2020-05-23 11:23:45 +01:00
|
|
|
- ssh-keys/mobile.pub
|
2020-05-23 11:04:50 +01:00
|
|
|
|
2020-04-28 20:48:15 +01:00
|
|
|
- name: Enable SSH
|
|
|
|
service:
|
|
|
|
name: sshd
|
|
|
|
enabled: true
|
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Restart SSH Daemon
|
2019-12-08 15:55:19 +00:00
|
|
|
service:
|
|
|
|
name: sshd
|
|
|
|
state: reloaded
|
|
|
|
when: sshd_config.changed
|
2020-01-17 22:31:50 +00:00
|
|
|
become: true
|