mirror of
https://github.com/fscotto/infra.git
synced 2026-09-27 19:03:47 +00:00
Allow configurable Aegis SSH users and authorized keys
This commit is contained in:
@@ -196,6 +196,10 @@ for AdGuard while retaining DNS learned from the router. Define
|
||||
`vault_aegis_icloudpd_apple_id` in Vault before applying it. iCloudPD still requires interactive MFA
|
||||
initialization after its first deployment.
|
||||
|
||||
New Aegis images create the `admin` account in Butane. Before configuring a newly imaged node, run its
|
||||
first playbook execution with `-e ansible_user=admin`; the SSH hardening role then permits that same
|
||||
account. Keep the inventory on `pi` until the existing node has been replaced.
|
||||
|
||||
Validate the profile before deployment:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -9,12 +9,14 @@ variant: fiot
|
||||
version: 1.0.0
|
||||
passwd:
|
||||
users:
|
||||
- name: pi
|
||||
- name: admin
|
||||
password_hash: "$6$bNDsU0XC5BxNJS5U$ENDGpdOUPJM3wcXBgNESCQkOqqQ9gN72/xEQoJsAI6QdsaY6mD4G5DBVIv7nHwHQOP35IH1oGRl.Uy3R2iUYQ1"
|
||||
groups:
|
||||
- wheel
|
||||
ssh_authorized_keys:
|
||||
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINrIxXjA3ffPwziKGR5gzc4gAoBehQPlnEMcXF4Wl0ZS ikaros"
|
||||
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEH/7GJfGt0ZVmKeEzceoFkFkeCXFryKK9vAbaip+HCx nymph"
|
||||
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA95wYlzpfN3rjUhpMeP4KHn8I6ZrjQXoDTgwgRIa++b siren"
|
||||
systemd:
|
||||
units:
|
||||
- name: sshd.service
|
||||
|
||||
@@ -9,5 +9,9 @@ ansible_ssh_use_tty: false
|
||||
|
||||
aegis_lan_subnet: 192.168.178.0/24
|
||||
aegis_adguard_web_port: 80
|
||||
aegis_ssh_authorized_keys:
|
||||
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINrIxXjA3ffPwziKGR5gzc4gAoBehQPlnEMcXF4Wl0ZS ikaros"
|
||||
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEH/7GJfGt0ZVmKeEzceoFkFkeCXFryKK9vAbaip+HCx nymph"
|
||||
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA95wYlzpfN3rjUhpMeP4KHn8I6ZrjQXoDTgwgRIa++b siren"
|
||||
|
||||
aegis_icloudpd_apple_id: "{{ vault_aegis_icloudpd_apple_id | default('') }}"
|
||||
|
||||
@@ -12,5 +12,6 @@ aegis_lan_subnet: CHANGEME_LAN_SUBNET
|
||||
aegis_firewalld_zone: public
|
||||
aegis_adguard_web_port: 80
|
||||
aegis_ssh_allowed_users:
|
||||
- pi
|
||||
- "{{ ansible_user }}"
|
||||
aegis_ssh_user_home: "/var/home/{{ ansible_user }}"
|
||||
aegis_ssh_authorized_keys: []
|
||||
|
||||
@@ -165,6 +165,16 @@
|
||||
path: "{{ aegis_ssh_user_home }}/.ssh/authorized_keys"
|
||||
register: aegis_authorized_keys
|
||||
|
||||
- name: Manage Aegis SSH authorized keys
|
||||
tags: [aegis, ssh, services]
|
||||
ansible.posix.authorized_key:
|
||||
user: "{{ ansible_user }}"
|
||||
key: "{{ aegis_ssh_authorized_keys | join('\n') }}"
|
||||
state: present
|
||||
exclusive: true
|
||||
manage_dir: true
|
||||
when: aegis_ssh_authorized_keys | length > 0
|
||||
|
||||
- name: Find Aegis SSH authorized key fragments
|
||||
tags: [aegis, ssh, services]
|
||||
ansible.builtin.find:
|
||||
@@ -178,7 +188,8 @@
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- >-
|
||||
(aegis_authorized_keys.stat.exists and aegis_authorized_keys.stat.size | int > 0)
|
||||
(aegis_ssh_authorized_keys | length > 0)
|
||||
or (aegis_authorized_keys.stat.exists and aegis_authorized_keys.stat.size | int > 0)
|
||||
or aegis_authorized_key_fragments.matched | int > 0
|
||||
fail_msg: Add a public key for the Ansible SSH user before disabling password authentication.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user