diff --git a/README.md b/README.md index 190ceae..3e17482 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/ansible/bootstrap/aegis.bu b/ansible/bootstrap/aegis.bu index b11c126..e09cbd9 100644 --- a/ansible/bootstrap/aegis.bu +++ b/ansible/bootstrap/aegis.bu @@ -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 diff --git a/ansible/inventory/host_vars/aegis.yml b/ansible/inventory/host_vars/aegis.yml index 298afa6..143577e 100644 --- a/ansible/inventory/host_vars/aegis.yml +++ b/ansible/inventory/host_vars/aegis.yml @@ -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('') }}" diff --git a/ansible/roles/profile_aegis/defaults/main.yml b/ansible/roles/profile_aegis/defaults/main.yml index bb8c5c5..2d63a59 100644 --- a/ansible/roles/profile_aegis/defaults/main.yml +++ b/ansible/roles/profile_aegis/defaults/main.yml @@ -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: [] diff --git a/ansible/roles/profile_aegis/tasks/main.yml b/ansible/roles/profile_aegis/tasks/main.yml index 03b4e44..ae49399 100644 --- a/ansible/roles/profile_aegis/tasks/main.yml +++ b/ansible/roles/profile_aegis/tasks/main.yml @@ -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.