GNAI-024: Litecoin-Wallet-LXC CT 114 — Doku, Ansible-Projekt, PVE-Skripte, Snapshots
ci-static / secret-scan (push) Successful in 20s
ci-static / yamllint (push) Successful in 31s
ci-static / ansible-syntax (push) Successful in 29s
ci-static / markdown-links (push) Successful in 20s

Nimmt die Research-Dokumente (litecoin-lxc-setup.txt, litecoin-lxc-tests.txt)
auf und prüft sie gegen die Repo-Konventionen (GNAI-024 Abschnitt 2):
Core v0.21.5.8 SHA256 gegen signiertes SHA256SUMS.asc verifiziert, RPC-Port
9332 (nicht 8332), nftables statt ufw, RPC per SSH-Exec statt Tunnel
(DisableForwarding), Cookie-Auth statt rpcauth, Backup-Ziel gn-backup auf
ghostnet-ki, vzdump-Abweichung mit Snapshot-Rolle, MWEB nie an Exchanges.

Neu: self-contained Ansible-Projekt proxmox/lxc/ct-114-litecoin-wallet/ansible
(3 Inventare, 5 Playbooks, 7 Rollen; nur öffentliche SSH-Keys im Repo),
PVE-Provisioning (provision-ct114-litecoin.sh + Bootstrap-Hook mit gepinnten
SHAs), Rolle pve_lxc_snapshot im pve-host-Projekt (täglich 04:00, Retention 7),
READMEs, Index-Einträge in GNAI-000 und proxmox-server README.

Workstation: SSH-Keys id_ed25519_ghostnet_ct114_{agent,ansible_deploy}
erzeugt, Aliase ghostnet-ct114-* in ~/.ssh/config. ghost-Key bleibt
Operator-Schritt (interaktive Passphrase).

Lokal bestanden: ansible --syntax-check, yamllint, secret_scan, check_links,
bash -n aller Skripte, Jinja-Render-Smoke-Test aller Templates.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
2026-11-25 17:06:36 +01:00
parent e7ae0c3a61
commit df5bbf0d70
79 changed files with 3269 additions and 1 deletions
@@ -0,0 +1,20 @@
# CT 114 – Litecoin wallet node
Host root for the Litecoin full-node LXC at `10.0.0.61` (`ltc-node`), planned
as a Tor-only cold wallet (GNAI-024). The container does not exist yet; it is
created on the PVE host by the operator with the reviewed helpers in
[`scripts/`](scripts/README.md) and then converged by the self-contained
Ansible project in [`ansible/`](ansible/README.md).
| Area | Content |
| --- | --- |
| [`ansible/`](ansible/README.md) | inventories (`agent`/`bootstrap`/`production`), playbooks and CT-specific roles |
| [`scripts/`](scripts/README.md) | reviewed PVE provisioning launcher and access bootstrap hook |
| [`../../../docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/GNAI-024-PLAN_Litecoin-Wallet-LXC.md`](../../../docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/GNAI-024-PLAN_Litecoin-Wallet-LXC.md) | design, review of the research documents, decisions, phases and acceptance tests |
| [`../../../docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/litecoin-lxc-setup.txt`](../../../docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/litecoin-lxc-setup.txt) | original research brief (Auftrag) |
| [`../../../docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/litecoin-lxc-tests.txt`](../../../docs/platform/proxmox-server/lxc/ct-114-litecoin-wallet/litecoin-lxc-tests.txt) | original research test plan (Auftrag) |
Secrets never enter this repository: no wallet passphrase, no seed, no
restic password, no private SSH keys. The wallet passphrase and restic
secret are handled interactively / via the operator's secret store
(Vaultwarden), and only public keys live in `ansible/files/ssh/`.
@@ -0,0 +1,65 @@
# CT 114 Litecoin wallet Ansible project
This self-contained host project manages the CT 114 Litecoin full-node LXC
(`ltc-node`, `10.0.0.61`). It follows the CT 102 Keycloak fresh-rebuild schema
and the CT 100/103 three-inventory convention (`agent`, `bootstrap`,
`production`) and uses the repository-wide pinned control dependency
(`shared/ansible/requirements-control.txt`); all CT 114 inventories,
playbooks, keys and roles remain inside the CT 114 root.
Create the repository-level control environment once:
```bash
python3 -m venv .venv
.venv/bin/python -m pip install --upgrade pip
.venv/bin/python -m pip install -r shared/ansible/requirements-control.txt
```
Run commands from this directory and always select an inventory explicitly:
```bash
cd proxmox/lxc/ct-114-litecoin-wallet/ansible
../../../../.venv/bin/ansible-playbook \
--inventory inventories/production/hosts.yml \
playbooks/verify-production.yml \
--private-key ~/.ssh/id_ed25519_ghostnet_ct114_ansible_deploy
```
## Commissioning sequence for the new CT 114
CT 114 does not exist yet; the LXC is created on the PVE host by the operator
with the reviewed helpers in [`../scripts/`](../scripts/) (Community Scripts
launcher + bootstrap hook), following the CT 102 procedure (GNAI-016 Phase D,
GNAI-024 Abschnitt 6):
0. Operator, on the workstation: generate the three CT 114 key pairs
(`ghost` interactively with passphrase; `ghost-agent`/`ansible-deploy`
passphrase-less), copy the `.pub` files into `files/ssh/`, fill the
`ADMIN_PUBLIC_KEY` placeholder in the bootstrap hook, then create the
restic backup key and the restic password on the target during bootstrap
(secrets never enter this repository).
1. Operator, as root@pve: install the reviewed hooks and run
`../scripts/provision-ct114-litecoin.sh`.
2. Operator: pin the SSH host-key fingerprint from the Proxmox console into
all three `host_vars/litecoin-ct114.yml` files, and add
`10.0.0.61` to the WireGuard server-admin target list on CT 105 if VPN
management access is wanted.
3. `preflight.yml` on the `agent` inventory (read-only, unprivileged,
`--private-key ~/.ssh/id_ed25519_ghostnet_ct114_agent`) proves identity,
resource gates and the empty state.
4. `verify-deploy-access.yml` on the `production` inventory proves the
`ansible-deploy` boundary.
5. `site.yml --check --diff` on the `production` inventory previews the
convergence. A real `site.yml` run enforces the declared state and
therefore requires explicit operator authorization.
6. `verify-production.yml` plus a second `site.yml` run with `changed=0`
complete the commissioning; `audit-production.yml` is the read-only deep
audit.
The node is started by `site.yml` only on inventories with
`litecoin_service_start_allowed: true` (production). Wallet creation and
`encryptwallet` are interactive operator/agent steps over SSH exec — never
part of a playbook (GNAI-024 Abschnitt 8).
Do not store the wallet passphrase, the restic password, the restic SSH
private key, any private SSH key or seed material in this repository.
@@ -0,0 +1,12 @@
[defaults]
home = .ansible
host_key_checking = True
interpreter_python = auto_silent
local_tmp = .ansible/tmp
retry_files_enabled = False
roles_path = roles:../../../../shared/ansible/roles
timeout = 15
[ssh_connection]
pipelining = True
ssh_args = -o ControlMaster=auto -o ControlPersist=60s
@@ -0,0 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILfqlYvqesJK9bhMmfv6tRp5pXPFDu13xmYbV+58fopV ansible-deploy@ghostnet-ct114
@@ -0,0 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMvQR56yADYULrpThnXROAa8GxKWfb+xcnIVLVDVX6Yy ghost-agent@ghostnet-ct114
@@ -0,0 +1,32 @@
---
ansible_become_method: sudo
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_common_args: >-
-o IdentitiesOnly=yes
-o StrictHostKeyChecking=yes
-o UserKnownHostsFile=~/.ssh/known_hosts_ghostnet_ct114
litecoin_expected_distribution: Debian
litecoin_expected_distribution_major_version: "13"
litecoin_expected_hostname: ltc-node
litecoin_expected_virtualization_type: lxc
litecoin_firewall_management_ipv4:
- 10.0.0.0/24
- 10.8.0.0/24
litecoin_firewall_ssh_port: 22
litecoin_access_source_networks: 10.0.0.0/24,10.8.0.0/24
litecoin_core_version: 0.21.5.8
litecoin_core_tarball_name: "litecoin-{{ litecoin_core_version }}-x86_64-linux-gnu.tar.gz"
litecoin_core_base_url: "https://download.litecoin.org/litecoin-{{ litecoin_core_version }}/linux"
# SHA-256 aus dem signierten SHA256SUMS.asc von download.litecoin.org
# (Release v0.21.5.8 vom 2026-09-12, enthaelt den 0.21.5.7-Sicherheitsfix),
# am 2026-11-25 gegen den offiziellen Download geprueft (GNAI-024 Abschnitt 2).
litecoin_core_tarball_sha256: >-
43200c9f9d65ebc126ea5833ca9429e144c4b3273da6bb9f4e89fd7450ab1be9
# Read-only access only; the agent inventory must never converge state.
litecoin_service_start_allowed: false
litecoin_service_production_enabled: false
@@ -0,0 +1,11 @@
---
litecoin_ctid: 114
litecoin_expected_ipv4: 10.0.0.61
# Wird nach dem ersten Boot des CT vom Operator aus der Proxmox-Konsole
# uebernommen (ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub via pct exec)
# und hier gepinnt. Der Platzhalter muss vor dem ersten Lauf ersetzt werden.
litecoin_expected_ssh_host_key_fingerprint: "SHA256:PENDING-operator-pins-after-first-boot"
litecoin_expected_processor_vcpus: 2
litecoin_minimum_memory_mb: 3800
litecoin_minimum_root_size_bytes: 150000000000
litecoin_minimum_root_available_bytes: 20000000000
@@ -0,0 +1,8 @@
---
all:
children:
litecoin_hosts:
hosts:
litecoin-ct114:
ansible_host: 10.0.0.61
ansible_user: ghost-agent
@@ -0,0 +1,29 @@
---
ansible_become_method: sudo
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_common_args: >-
-o IdentitiesOnly=yes
-o StrictHostKeyChecking=yes
-o UserKnownHostsFile=~/.ssh/known_hosts_ghostnet_ct114
litecoin_expected_distribution: Debian
litecoin_expected_distribution_major_version: "13"
litecoin_expected_hostname: ltc-node
litecoin_expected_virtualization_type: lxc
litecoin_firewall_management_ipv4:
- 10.0.0.0/24
- 10.8.0.0/24
litecoin_firewall_ssh_port: 22
litecoin_access_source_networks: 10.0.0.0/24,10.8.0.0/24
litecoin_core_version: 0.21.5.8
litecoin_core_tarball_name: "litecoin-{{ litecoin_core_version }}-x86_64-linux-gnu.tar.gz"
litecoin_core_base_url: "https://download.litecoin.org/litecoin-{{ litecoin_core_version }}/linux"
litecoin_core_tarball_sha256: >-
43200c9f9d65ebc126ea5833ca9429e144c4b3273da6bb9f4e89fd7450ab1be9
# Bootstrap converges configuration but must not start the node yet.
litecoin_service_start_allowed: false
litecoin_service_production_enabled: false
@@ -0,0 +1,8 @@
---
litecoin_ctid: 114
litecoin_expected_ipv4: 10.0.0.61
litecoin_expected_ssh_host_key_fingerprint: "SHA256:PENDING-operator-pins-after-first-boot"
litecoin_expected_processor_vcpus: 2
litecoin_minimum_memory_mb: 3800
litecoin_minimum_root_size_bytes: 150000000000
litecoin_minimum_root_available_bytes: 20000000000
@@ -0,0 +1,8 @@
---
all:
children:
litecoin_hosts:
hosts:
litecoin-ct114:
ansible_host: 10.0.0.61
ansible_user: ghost
@@ -0,0 +1,37 @@
---
ansible_become_method: sudo
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_common_args: >-
-o IdentitiesOnly=yes
-o StrictHostKeyChecking=yes
-o UserKnownHostsFile=~/.ssh/known_hosts_ghostnet_ct114
litecoin_expected_distribution: Debian
litecoin_expected_distribution_major_version: "13"
litecoin_expected_hostname: ltc-node
litecoin_expected_virtualization_type: lxc
litecoin_firewall_management_ipv4:
- 10.0.0.0/24
- 10.8.0.0/24
litecoin_firewall_ssh_port: 22
litecoin_access_source_networks: 10.0.0.0/24,10.8.0.0/24
litecoin_core_version: 0.21.5.8
litecoin_core_tarball_name: "litecoin-{{ litecoin_core_version }}-x86_64-linux-gnu.tar.gz"
litecoin_core_base_url: "https://download.litecoin.org/litecoin-{{ litecoin_core_version }}/linux"
# SHA-256 aus dem signierten SHA256SUMS.asc von download.litecoin.org
# (Release v0.21.5.8 vom 2026-09-12, enthaelt den 0.21.5.7-Sicherheitsfix),
# am 2026-11-25 gegen den offiziellen Download geprueft (GNAI-024 Abschnitt 2).
litecoin_core_tarball_sha256: >-
43200c9f9d65ebc126ea5833ca9429e144c4b3273da6bb9f4e89fd7450ab1be9
# restic-Ziel auf dem hostunabhaengigen Backup-Ziel ghostnet-ki (10.0.0.90),
# Konto gn-backup; clientseitige Verschluesselung ist restic-Standard.
# Alternativ liefert der Betreiber die Zugangsdaten eines separaten PBS im LAN.
litecoin_backup_repository: "sftp:gn-backup@10.0.0.90:/var/lib/ghostnet-ai-backup/ct114/restic"
litecoin_backup_keep_daily: 30
litecoin_service_start_allowed: true
litecoin_service_production_enabled: true
@@ -0,0 +1,11 @@
---
litecoin_ctid: 114
litecoin_expected_ipv4: 10.0.0.61
# Wird nach dem ersten Boot des CT vom Operator aus der Proxmox-Konsole
# uebernommen (pct exec 114 -- ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub)
# und hier gepinnt. Der Platzhalter muss vor dem ersten Lauf ersetzt werden.
litecoin_expected_ssh_host_key_fingerprint: "SHA256:PENDING-operator-pins-after-first-boot"
litecoin_expected_processor_vcpus: 2
litecoin_minimum_memory_mb: 3800
litecoin_minimum_root_size_bytes: 150000000000
litecoin_minimum_root_available_bytes: 20000000000
@@ -0,0 +1,8 @@
---
all:
children:
litecoin_hosts:
hosts:
litecoin-ct114:
ansible_host: 10.0.0.61
ansible_user: ansible-deploy
@@ -0,0 +1,181 @@
---
- name: Read-only deep audit of the CT 114 production state
hosts: litecoin_hosts
become: true
gather_facts: true
gather_subset:
- min
- network
- virtual
tasks:
- name: Require the production inventory safeguards
ansible.builtin.assert:
that:
- litecoin_ctid | int == 114
- inventory_hostname == "litecoin-ct114"
- >-
litecoin_expected_ssh_host_key_fingerprint is
match('^SHA256:[A-Za-z0-9+/]{43}$')
- name: Read the account inventory
ansible.builtin.command:
argv: [/usr/bin/getent, passwd]
check_mode: false
changed_when: false
register: litecoin_audit_passwd
- name: Require exactly the managed accounts with their fixed UIDs
ansible.builtin.assert:
that:
- litecoin_audit_passwd.stdout is search('(?m)^ghost-agent:x:1000:1000:')
- litecoin_audit_passwd.stdout is search('(?m)^ghost:x:1001:1001:')
- litecoin_audit_passwd.stdout is search('(?m)^ansible-deploy:x:1002:1002:')
- litecoin_audit_passwd.stdout is search('(?m)^litecoin:x:1100:1100:')
- name: Read the password states of the managed accounts
ansible.builtin.command:
argv: [/usr/bin/passwd, -S, "{{ item }}"]
check_mode: false
changed_when: false
register: litecoin_audit_password_states
loop:
- ghost-agent
- ghost
- ansible-deploy
- litecoin
loop_control:
label: "{{ item }}"
- name: Require locked or password-gated states only
ansible.builtin.assert:
that:
- item.stdout.split()[1] in ["L", "P"]
loop: "{{ litecoin_audit_password_states.results }}"
loop_control:
label: "{{ item.item }}"
- name: Read the sudoers drop-ins
ansible.builtin.command:
argv: [/usr/bin/cat, /etc/sudoers.d/90-ghostnet-ansible-deploy, /etc/sudoers.d/91-ghostnet-litecoin-readonly]
check_mode: false
changed_when: false
register: litecoin_audit_sudoers
- name: Require the validated sudo policies
ansible.builtin.assert:
that:
- litecoin_audit_sudoers.stdout is search('ansible-deploy ALL=\\(root\\) NOPASSWD: ALL')
- litecoin_audit_sudoers.stdout is search('ghost-agent ALL=\\(root\\) NOPASSWD: /usr/local/bin/ltc-readonly')
- name: Verify the sudoers files pass visudo
ansible.builtin.command:
argv: [/usr/sbin/visudo, -c, -f, "{{ item }}"]
check_mode: false
changed_when: false
loop:
- /etc/sudoers.d/90-ghostnet-ansible-deploy
- /etc/sudoers.d/91-ghostnet-litecoin-readonly
loop_control:
label: "{{ item }}"
- name: Read the effective SSH configuration
ansible.builtin.command:
argv: [/usr/sbin/sshd, -T]
check_mode: false
changed_when: false
register: litecoin_audit_sshd
- name: Require the GNAI-011 SSH baseline
ansible.builtin.assert:
that:
- litecoin_audit_sshd.stdout is search('(?m)^permitrootlogin no$')
- litecoin_audit_sshd.stdout is search('(?m)^passwordauthentication no$')
- litecoin_audit_sshd.stdout is search('(?m)^kbdinteractiveauthentication no$')
- litecoin_audit_sshd.stdout is search('(?m)^allowtcpforwarding no$')
- litecoin_audit_sshd.stdout is search('(?m)^disableforwarding yes$')
- litecoin_audit_sshd.stdout is search('(?m)^allowusers ghost-agent ghost ansible-deploy$')
- name: Read the fail2ban jail list
ansible.builtin.command:
argv: [/usr/bin/fail2ban-client, status]
check_mode: false
changed_when: false
register: litecoin_audit_fail2ban
- name: Require the sshd jail
ansible.builtin.assert:
that:
- litecoin_audit_fail2ban.stdout is search('sshd')
- name: Read the active nftables ruleset
ansible.builtin.command:
argv: [/usr/sbin/nft, list, ruleset]
check_mode: false
changed_when: false
register: litecoin_audit_nft
- name: Require the Ghostnet filter table in the ruleset
ansible.builtin.assert:
that:
- litecoin_audit_nft.stdout is search('table inet ghostnet_filter')
- name: Read the Tor client configuration
ansible.builtin.command:
argv: [/usr/bin/tor, --verify-config, -f, /etc/tor/torrc]
check_mode: false
changed_when: false
register: litecoin_audit_tor_config
- name: Require the Tor config to verify
ansible.builtin.assert:
that:
- litecoin_audit_tor_config.rc == 0
- name: Read the litecoind network state via the read-only wrapper path
become: false
ansible.builtin.command:
argv: [/usr/bin/sudo, -n, -u, litecoin, /opt/litecoin/bin/litecoin-cli, -conf=/etc/litecoin/litecoin.conf, getnetworkinfo]
check_mode: false
changed_when: false
register: litecoin_audit_networkinfo
when: not ansible_check_mode
- name: Require onion-only networking when the node is running
ansible.builtin.assert:
that:
- >-
'"onion"' in litecoin_audit_networkinfo.stdout
- >-
litecoin_audit_networkinfo.stdout is not
search('"name": "(ipv4|ipv6)"')
when:
- not ansible_check_mode
- litecoin_service_start_allowed | bool
- name: Read the litecoind datadir usage
ansible.builtin.command:
argv: [/usr/bin/du, -sb, /var/lib/litecoin]
check_mode: false
changed_when: false
register: litecoin_audit_datadir_usage
- name: Read the wallet backup directory state
ansible.builtin.stat:
path: /var/lib/litecoin/backups
register: litecoin_audit_backup_dir
- name: Require the protected wallet backup directory
ansible.builtin.assert:
that:
- litecoin_audit_backup_dir.stat.exists
- litecoin_audit_backup_dir.stat.mode == "0700"
- litecoin_audit_backup_dir.stat.pw_name == "litecoin"
- name: Report the CT 114 audit summary
ansible.builtin.debug:
msg:
ctid: "{{ litecoin_ctid }}"
ssh_fingerprint: "{{ litecoin_expected_ssh_host_key_fingerprint }}"
datadir_bytes: "{{ litecoin_audit_datadir_usage.stdout.split()[0] }}"
fail2ban_jails: "{{ litecoin_audit_fail2ban.stdout_lines }}"
@@ -0,0 +1,175 @@
---
- name: Read-only verification of the fresh CT 114 Litecoin LXC
hosts: litecoin_hosts
become: false
gather_facts: true
gather_subset:
- min
- hardware
- network
- virtual
tasks:
- name: Verify required inventory safeguards are defined
ansible.builtin.assert:
that:
- litecoin_ctid is defined
- litecoin_expected_hostname is defined
- litecoin_expected_ipv4 is defined
- litecoin_expected_ssh_host_key_fingerprint is defined
- litecoin_expected_distribution is defined
- litecoin_expected_distribution_major_version is defined
- litecoin_expected_virtualization_type is defined
- litecoin_minimum_memory_mb is defined
- litecoin_minimum_root_size_bytes is defined
fail_msg: >-
The selected inventory lacks mandatory CT 114 identity safeguards.
Stop before running any configuration playbook.
- name: Verify the expected guest identity
ansible.builtin.assert:
that:
- inventory_hostname == "litecoin-ct114"
- litecoin_ctid | int == 114
- ansible_facts["hostname"] == litecoin_expected_hostname
- ansible_facts["distribution"] == litecoin_expected_distribution
- >-
ansible_facts["distribution_major_version"] ==
litecoin_expected_distribution_major_version
- >-
ansible_facts["default_ipv4"]["address"] ==
litecoin_expected_ipv4
- >-
ansible_facts["virtualization_type"] ==
litecoin_expected_virtualization_type
- ansible_facts["virtualization_role"] == "guest"
- ansible_facts["service_mgr"] == "systemd"
- ansible_facts["python"]["version"]["major"] | int >= 3
fail_msg: >-
The connected machine is not the expected CT 114 Litecoin LXC.
Stop before using any privileged playbook.
success_msg: The expected Debian 13 CT 114 Litecoin LXC is connected.
- name: Verify the pinned SSH host key fingerprint
ansible.builtin.assert:
that:
- litecoin_expected_ssh_host_key_fingerprint is
match('^SHA256:[A-Za-z0-9+/]{43}$')
fail_msg: >-
litecoin_expected_ssh_host_key_fingerprint still contains the
PENDING placeholder. Pin the real fingerprint from the Proxmox
console after the first boot (GNAI-024 Abschnitt 6).
- name: Read the unprivileged SSH identity
ansible.builtin.command:
argv:
- /usr/bin/id
- -un
check_mode: false
changed_when: false
register: litecoin_preflight_ssh_identity
- name: Verify the agent account was used on the agent inventory
ansible.builtin.assert:
that:
- litecoin_preflight_ssh_identity.stdout == "ghost-agent"
fail_msg: >-
The agent inventory must connect through the unprivileged
ghost-agent account.
when: ansible_user is defined and ansible_user == "ghost-agent"
- name: Read failed systemd units
ansible.builtin.command:
argv:
- /usr/bin/systemctl
- --failed
- --no-legend
- --plain
check_mode: false
changed_when: false
register: litecoin_preflight_failed_units
- name: Read the listening TCP ports
ansible.builtin.command:
argv:
- /usr/bin/ss
- -H
- -lnt
check_mode: false
changed_when: false
register: litecoin_preflight_listeners
- name: Read the effective processor count
ansible.builtin.command:
argv:
- /usr/bin/nproc
check_mode: false
changed_when: false
register: litecoin_preflight_nproc
- name: Read root filesystem capacity
ansible.builtin.command:
argv:
- /usr/bin/findmnt
- --bytes
- --noheadings
- --output
- SIZE,AVAIL
- --target
- /
check_mode: false
changed_when: false
register: litecoin_preflight_root_capacity
- name: Check that no Litecoin installation exists yet
ansible.builtin.stat:
path: /opt/litecoin
register: litecoin_preflight_opt_symlink
- name: Verify the fresh-LXC commissioning gates
ansible.builtin.assert:
that:
- >-
litecoin_preflight_nproc.stdout | int ==
litecoin_expected_processor_vcpus | int
- >-
ansible_facts["memtotal_mb"] | int >=
litecoin_minimum_memory_mb | int
- >-
litecoin_preflight_root_capacity.stdout.split()[0] | int >=
litecoin_minimum_root_size_bytes | int
- >-
litecoin_preflight_root_capacity.stdout.split()[1] | int >=
litecoin_minimum_root_available_bytes | int
- litecoin_preflight_failed_units.stdout | trim == ""
- >-
litecoin_preflight_listeners.stdout is search('\\b22\\b') or
litecoin_preflight_listeners.stdout | trim == ""
- not litecoin_preflight_opt_symlink.stat.exists
fail_msg: >-
The target is not the expected healthy, empty CT 114. Stop before
creating configuration, services or wallets.
success_msg: >-
CT 114 is healthy, empty and ready for declarative configuration.
- name: Report the verified Litecoin commissioning baseline
ansible.builtin.debug:
msg:
inventory_host: "{{ inventory_hostname }}"
ctid: "{{ litecoin_ctid }}"
hostname: "{{ ansible_facts['hostname'] }}"
operating_system: >-
{{ ansible_facts['distribution'] }}
{{ ansible_facts['distribution_version'] }}
default_ipv4: "{{ ansible_facts['default_ipv4']['address'] }}"
virtualization: >-
{{ ansible_facts['virtualization_type'] }}
{{ ansible_facts['virtualization_role'] }}
effective_processor_count: "{{ litecoin_preflight_nproc.stdout }}"
memory_mib: "{{ ansible_facts['memtotal_mb'] }}"
root_size_bytes: >-
{{ litecoin_preflight_root_capacity.stdout.split()[0] }}
root_available_bytes: >-
{{ litecoin_preflight_root_capacity.stdout.split()[1] }}
trusted_ssh_fingerprint: >-
{{ litecoin_expected_ssh_host_key_fingerprint }}
@@ -0,0 +1,29 @@
---
- name: Converge the CT 114 Litecoin wallet LXC on the declared state
hosts: litecoin_hosts
become: true
gather_facts: true
gather_subset:
- min
- hardware
- network
- virtual
roles:
- role: litecoin_lxc_baseline
vars:
litecoin_lxc_baseline_expected_hostname: >-
{{ litecoin_expected_hostname }}
litecoin_lxc_baseline_expected_distribution: >-
{{ litecoin_expected_distribution }}
litecoin_lxc_baseline_expected_distribution_major_version: >-
{{ litecoin_expected_distribution_major_version }}
litecoin_lxc_baseline_expected_ipv4: "{{ litecoin_expected_ipv4 }}"
litecoin_lxc_baseline_expected_virtualization_type: >-
{{ litecoin_expected_virtualization_type }}
- role: litecoin_access
- role: litecoin_firewall
- role: litecoin_fail2ban
- role: litecoin_tor
- role: litecoin_core
- role: litecoin_backup
@@ -0,0 +1,43 @@
---
- name: Verify the CT 114 Ansible deployment boundary
hosts: litecoin_hosts
become: false
gather_facts: false
tasks:
- name: Verify Ansible module execution without privilege escalation
ansible.builtin.ping:
- name: Read the SSH account identity
ansible.builtin.command:
argv:
- /usr/bin/id
- -un
check_mode: false
changed_when: false
register: litecoin_deploy_account_identity
- name: Verify the expected SSH account
ansible.builtin.assert:
that:
- litecoin_deploy_account_identity.stdout == "ansible-deploy"
fail_msg: The SSH connection did not use ansible-deploy.
- name: Read the effective identity through sudo
become: true
ansible.builtin.command:
argv:
- /usr/bin/id
- -u
check_mode: false
changed_when: false
register: litecoin_deploy_root_identity
- name: Verify non-interactive root escalation
ansible.builtin.assert:
that:
- litecoin_deploy_root_identity.stdout == "0"
fail_msg: Non-interactive sudo did not produce effective UID 0.
success_msg: >-
The CT 114 deployment account can connect and escalate privileges
non-interactively.
@@ -0,0 +1,213 @@
---
- name: Read-only verification of the converged CT 114 production state
hosts: litecoin_hosts
become: true
gather_facts: true
gather_subset:
- min
- network
- virtual
tasks:
- name: Require the production inventory safeguards
ansible.builtin.assert:
that:
- litecoin_ctid | int == 114
- inventory_hostname == "litecoin-ct114"
- >-
litecoin_expected_ssh_host_key_fingerprint is
match('^SHA256:[A-Za-z0-9+/]{43}$')
- name: Verify the expected guest identity
ansible.builtin.assert:
that:
- ansible_facts["hostname"] == litecoin_expected_hostname
- ansible_facts["distribution"] == litecoin_expected_distribution
- >-
ansible_facts["distribution_major_version"] ==
litecoin_expected_distribution_major_version
- >-
ansible_facts["default_ipv4"]["address"] ==
litecoin_expected_ipv4
- >-
ansible_facts["virtualization_type"] ==
litecoin_expected_virtualization_type
- ansible_facts["virtualization_role"] == "guest"
fail_msg: The connected machine is not the declared CT 114.
- name: Read failed systemd units
ansible.builtin.command:
argv: [/usr/bin/systemctl, --failed, --no-legend, --plain]
check_mode: false
changed_when: false
register: litecoin_production_failed_units
- name: Require no failed units
ansible.builtin.assert:
that:
- litecoin_production_failed_units.stdout | trim == ""
- name: Read the deployment account identity
become: false
ansible.builtin.command:
argv: [/usr/bin/id, -un]
check_mode: false
changed_when: false
register: litecoin_production_ssh_identity
- name: Require the deployment account
ansible.builtin.assert:
that:
- litecoin_production_ssh_identity.stdout == "ansible-deploy"
- name: Read the required service states
ansible.builtin.command:
argv:
- /usr/bin/systemctl
- is-active
- ssh.service
- nftables.service
- fail2ban.service
- tor.service
- unattended-upgrades.service
check_mode: false
changed_when: false
register: litecoin_production_services
- name: Require all management services active
ansible.builtin.assert:
that:
- litecoin_production_services.stdout_lines | select('!=', 'active') | list | length == 0
- name: Read the litecoind service state
ansible.builtin.command:
argv: [/usr/bin/systemctl, is-active, litecoind.service]
check_mode: false
changed_when: false
register: litecoin_production_litecoind
- name: Require litecoind active when the inventory allows starting it
ansible.builtin.assert:
that:
- litecoin_production_litecoind.stdout == "active"
when: litecoin_service_start_allowed | bool
- name: Read the listening TCP sockets
ansible.builtin.command:
argv: [/usr/bin/ss, -H, -lnt]
check_mode: false
changed_when: false
register: litecoin_production_listeners
- name: Require SSH as the only externally bound listener
ansible.builtin.assert:
that:
- litecoin_production_listeners.stdout is search('0.0.0.0:22\\b|\\[::\\]:22\\b')
- not (litecoin_production_listeners.stdout is search('0.0.0.0:(9332|9333|9050|9051)\\b'))
- not (litecoin_production_listeners.stdout is search('\\[::\\]:(9332|9333|9050|9051)\\b'))
fail_msg: >-
Unexpected externally bound listener. RPC 9332, SOCKS 9050,
ControlPort 9051 and P2P 9333 must be loopback-only or absent.
- name: Require loopback-only RPC and Tor listeners
ansible.builtin.assert:
that:
- litecoin_production_listeners.stdout is search('127.0.0.1:9332\\b')
- litecoin_production_listeners.stdout is search('127.0.0.1:9050\\b')
- not (litecoin_production_listeners.stdout is search('9333'))
fail_msg: >-
litecoind must bind RPC to 127.0.0.1:9332 only and must not listen
on P2P 9333 (listen=0, onion-only).
- name: Read the litecoind version
ansible.builtin.command:
argv: [/opt/litecoin/bin/litecoind, --version]
check_mode: false
changed_when: false
register: litecoin_production_version
- name: Require the pinned Litecoin Core version
ansible.builtin.assert:
that:
- ('Litecoin Core version v' ~ litecoin_core_version) in litecoin_production_version.stdout
fail_msg: "Unexpected litecoind version: {{ litecoin_production_version.stdout }}"
- name: Read the active Ghostnet nftables table
ansible.builtin.command:
argv: [/usr/sbin/nft, list, table, inet, ghostnet_filter]
check_mode: false
changed_when: false
register: litecoin_production_nft
- name: Require the default-deny firewall
ansible.builtin.assert:
that:
- litecoin_production_nft.stdout is search('policy drop')
- litecoin_production_nft.stdout is search('SSH management')
- litecoin_production_nft.stdout is search('default input deny')
- name: Read the effective SSH policy
ansible.builtin.command:
argv: [/usr/sbin/sshd, -T]
check_mode: false
changed_when: false
register: litecoin_production_sshd_effective
- name: Require the hardened SSH policy
ansible.builtin.assert:
that:
- litecoin_production_sshd_effective.stdout is search('(?m)^permitrootlogin no$')
- litecoin_production_sshd_effective.stdout is search('(?m)^passwordauthentication no$')
- litecoin_production_sshd_effective.stdout is search('(?m)^allowtcpforwarding no$')
- litecoin_production_sshd_effective.stdout is search('(?m)^disableforwarding yes$')
- name: Read the litecoin.conf permissions
ansible.builtin.stat:
path: /etc/litecoin/litecoin.conf
register: litecoin_production_conf_stat
- name: Require the protected litecoin.conf
ansible.builtin.assert:
that:
- litecoin_production_conf_stat.stat.mode == "0640"
- litecoin_production_conf_stat.stat.pw_name == "root"
- litecoin_production_conf_stat.stat.gr_name == "litecoin"
- name: Read the restic password file state without reading its content
ansible.builtin.stat:
path: /etc/litecoin-backup/restic-password
get_checksum: false
register: litecoin_production_restic_password_stat
- name: Require the operator-provided restic secret with safe permissions
ansible.builtin.assert:
that:
- litecoin_production_restic_password_stat.stat.exists
- litecoin_production_restic_password_stat.stat.mode == "0600"
- litecoin_production_restic_password_stat.stat.pw_name == "root"
fail_msg: >-
/etc/litecoin-backup/restic-password must exist as root:root 0600;
the operator installs it once (GNAI-024 Abschnitt 6 Schritt 0).
- name: Read the enabled backup timers
ansible.builtin.command:
argv: [/usr/bin/systemctl, list-timers, --no-legend, litecoin-wallet-backup.timer, litecoin-restic-check.timer]
check_mode: false
changed_when: false
register: litecoin_production_timers
- name: Require both backup timers
ansible.builtin.assert:
that:
- litecoin_production_timers.stdout is search('litecoin-wallet-backup.timer')
- litecoin_production_timers.stdout is search('litecoin-restic-check.timer')
- name: Report the verified CT 114 production state
ansible.builtin.debug:
msg:
ctid: "{{ litecoin_ctid }}"
ipv4: "{{ ansible_facts['default_ipv4']['address'] }}"
litecoind: "{{ litecoin_production_version.stdout.splitlines()[0] }}"
listeners: "{{ litecoin_production_listeners.stdout_lines }}"
services: "{{ litecoin_production_services.stdout_lines }}"
ssh_fingerprint: "{{ litecoin_expected_ssh_host_key_fingerprint }}"
@@ -0,0 +1,18 @@
# litecoin_access
Access model for CT 114, mirroring `keycloak_access` / GNAI-011:
- `ghost-agent` (1000, locked, no groups): `restrict,from="10.0.0.0/24,10.8.0.0/24"`
key plus a NOPASSWD sudo rule limited to `/usr/local/bin/ltc-readonly`, a
wrapper that whitelists read-only `litecoin-cli` calls and runs them as the
`litecoin` user (cookie auth, no stored RPC credentials).
- `ghost` (1001, password-gated sudo): personal admin key with forwarding
restrictions.
- `ansible-deploy` (1002, locked, `NOPASSWD: ALL`): `restrict,from=...` key.
- Root SSH emptied, `PermitRootLogin no`, password auth off, socket activation
off, and `DisableForwarding yes` — therefore no SSH port forwarding; the
Litecoin RPC (127.0.0.1:9332) is only used via SSH exec, never via tunnel.
All public keys come from `ansible/files/ssh/`; the role fails closed when a
key file is missing (the `ghost` key is generated interactively by the
operator before the first converge — GNAI-024 Abschnitt 6 Schritt 0).
@@ -0,0 +1,37 @@
---
litecoin_access_source_networks: 10.0.0.0/24,10.8.0.0/24
litecoin_access_public_key_root: "{{ playbook_dir }}/../files/ssh"
litecoin_access_agent_user: ghost-agent
litecoin_access_agent_uid: 1000
litecoin_access_agent_public_key_file: >-
{{ litecoin_access_public_key_root }}/litecoin-ghost-agent.pub
litecoin_access_admin_user: ghost
litecoin_access_admin_uid: 1001
litecoin_access_admin_public_key_file: >-
{{ litecoin_access_public_key_root }}/litecoin-ghost.pub
litecoin_access_deploy_user: ansible-deploy
litecoin_access_deploy_uid: 1002
litecoin_access_deploy_public_key_file: >-
{{ litecoin_access_public_key_root }}/litecoin-ansible-deploy.pub
litecoin_access_ssh_dropin: /etc/ssh/sshd_config.d/99-ghostnet-litecoin.conf
litecoin_access_sudoers_file: /etc/sudoers.d/90-ghostnet-ansible-deploy
litecoin_access_readonly_sudoers_file: /etc/sudoers.d/91-ghostnet-litecoin-readonly
litecoin_access_readonly_wrapper: /usr/local/bin/ltc-readonly
# Read-only litecoin-cli calls the agent account may run via the wrapper.
# Sending coins is deliberately not in this list; it stays an interactive
# `sudo -u litecoin litecoin-cli ...` action by ghost/ansible-deploy after an
# explicit walletpassphrase unlock (GNAI-024 Abschnitt 8).
litecoin_access_readonly_commands:
- getbalance
- getblockchaininfo
- getblockcount
- getmempoolinfo
- getnetworkinfo
- getpeerinfo
- getwalletinfo
- listtransactions
@@ -0,0 +1,5 @@
---
- name: Restart the classic SSH service
ansible.builtin.systemd_service:
name: ssh.service
state: restarted
@@ -0,0 +1,225 @@
---
- name: Require all three role-specific public keys in files/ssh
ansible.builtin.stat:
path: "{{ item }}"
loop:
- "{{ litecoin_access_agent_public_key_file }}"
- "{{ litecoin_access_admin_public_key_file }}"
- "{{ litecoin_access_deploy_public_key_file }}"
register: litecoin_access_public_keys
- name: Fail with a clear message when a public key is missing
ansible.builtin.fail:
msg: >-
Missing public key {{ item.item }}. The operator generates the CT 114
key pairs (the ghost key interactively with passphrase) and copies the
.pub files into ansible/files/ssh/ before converging (GNAI-024
Abschnitt 6, Schritt 0).
when: not item.stat.exists
loop: "{{ litecoin_access_public_keys.results }}"
loop_control:
label: "{{ item.item }}"
- name: Validate the public key files are real OpenSSH keys
ansible.builtin.command:
argv:
- /usr/bin/ssh-keygen
- -l
- -f
- "{{ item }}"
check_mode: false
changed_when: false
loop:
- "{{ litecoin_access_agent_public_key_file }}"
- "{{ litecoin_access_admin_public_key_file }}"
- "{{ litecoin_access_deploy_public_key_file }}"
loop_control:
label: "{{ item }}"
- name: Create fixed primary groups for Litecoin access accounts
ansible.builtin.group:
name: "{{ item.name }}"
gid: "{{ item.uid }}"
state: present
loop:
- name: "{{ litecoin_access_agent_user }}"
uid: "{{ litecoin_access_agent_uid }}"
- name: "{{ litecoin_access_admin_user }}"
uid: "{{ litecoin_access_admin_uid }}"
- name: "{{ litecoin_access_deploy_user }}"
uid: "{{ litecoin_access_deploy_uid }}"
loop_control:
label: "{{ item.name }}"
- name: Create fixed Litecoin access accounts
ansible.builtin.user:
name: "{{ item.name }}"
uid: "{{ item.uid }}"
group: "{{ item.name }}"
home: "/home/{{ item.name }}"
shell: /bin/bash
create_home: true
state: present
loop:
- name: "{{ litecoin_access_agent_user }}"
uid: "{{ litecoin_access_agent_uid }}"
- name: "{{ litecoin_access_admin_user }}"
uid: "{{ litecoin_access_admin_uid }}"
- name: "{{ litecoin_access_deploy_user }}"
uid: "{{ litecoin_access_deploy_uid }}"
loop_control:
label: "{{ item.name }}"
- name: Keep the read-only agent outside supplementary groups
ansible.builtin.user:
name: "{{ litecoin_access_agent_user }}"
groups: ""
append: false
password_lock: true
- name: Keep the deployment account outside supplementary groups
ansible.builtin.user:
name: "{{ litecoin_access_deploy_user }}"
groups: ""
append: false
password_lock: true
- name: Grant password-gated sudo membership to the administrator
ansible.builtin.user:
name: "{{ litecoin_access_admin_user }}"
groups:
- sudo
append: true
- name: Create protected SSH directories
ansible.builtin.file:
path: "/home/{{ item }}/.ssh"
state: directory
owner: "{{ item }}"
group: "{{ item }}"
mode: "0700"
loop:
- "{{ litecoin_access_agent_user }}"
- "{{ litecoin_access_admin_user }}"
- "{{ litecoin_access_deploy_user }}"
- name: Install the restricted read-only agent key
ansible.builtin.copy:
content: |
restrict,from="{{ litecoin_access_source_networks }}" {{ lookup('ansible.builtin.file', litecoin_access_agent_public_key_file) }}
dest: "/home/{{ litecoin_access_agent_user }}/.ssh/authorized_keys"
owner: "{{ litecoin_access_agent_user }}"
group: "{{ litecoin_access_agent_user }}"
mode: "0600"
- name: Install the restricted personal administrator key
ansible.builtin.copy:
content: |
from="{{ litecoin_access_source_networks }}",no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc {{ lookup('ansible.builtin.file', litecoin_access_admin_public_key_file) }}
dest: "/home/{{ litecoin_access_admin_user }}/.ssh/authorized_keys"
owner: "{{ litecoin_access_admin_user }}"
group: "{{ litecoin_access_admin_user }}"
mode: "0600"
- name: Install the restricted deployment key
ansible.builtin.copy:
content: |
restrict,from="{{ litecoin_access_source_networks }}" {{ lookup('ansible.builtin.file', litecoin_access_deploy_public_key_file) }}
dest: "/home/{{ litecoin_access_deploy_user }}/.ssh/authorized_keys"
owner: "{{ litecoin_access_deploy_user }}"
group: "{{ litecoin_access_deploy_user }}"
mode: "0600"
- name: Install validated deployment sudo policy
ansible.builtin.copy:
content: |
{{ litecoin_access_deploy_user }} ALL=(root) NOPASSWD: ALL
dest: "{{ litecoin_access_sudoers_file }}"
owner: root
group: root
mode: "0440"
validate: /usr/sbin/visudo -cf %s
- name: Install the read-only wrapper for the agent account
ansible.builtin.template:
src: ltc-readonly.sh.j2
dest: "{{ litecoin_access_readonly_wrapper }}"
owner: root
group: root
mode: "0750"
validate: /bin/bash -n %s
- name: Install validated read-only sudo policy for the agent account
ansible.builtin.copy:
content: |
{{ litecoin_access_agent_user }} ALL=(root) NOPASSWD: {{ litecoin_access_readonly_wrapper }}
dest: "{{ litecoin_access_readonly_sudoers_file }}"
owner: root
group: root
mode: "0440"
validate: /usr/sbin/visudo -cf %s
- name: Ensure root has no SSH authorization material
ansible.builtin.file:
path: /root/.ssh
state: directory
owner: root
group: root
mode: "0700"
- name: Keep the root authorized keys file empty
ansible.builtin.copy:
content: ""
dest: /root/.ssh/authorized_keys
owner: root
group: root
mode: "0600"
- name: Install the hardened SSH policy
ansible.builtin.template:
src: sshd.conf.j2
dest: "{{ litecoin_access_ssh_dropin }}"
owner: root
group: root
mode: "0600"
validate: /usr/sbin/sshd -t -f %s
notify: Restart the classic SSH service
- name: Disable SSH socket activation
ansible.builtin.systemd_service:
name: ssh.socket
enabled: false
state: stopped
- name: Enable the classic SSH service
ansible.builtin.systemd_service:
name: ssh.service
enabled: true
state: started
- name: Read account password states
ansible.builtin.command:
argv:
- /usr/bin/passwd
- -S
- "{{ item }}"
check_mode: false
changed_when: false
register: litecoin_access_password_states
loop:
- "{{ litecoin_access_agent_user }}"
- "{{ litecoin_access_admin_user }}"
- "{{ litecoin_access_deploy_user }}"
loop_control:
label: "{{ item }}"
- name: Verify the locked password states
ansible.builtin.assert:
that:
- item.stdout.split()[1] in ["L", "P"]
fail_msg: >-
Account {{ item.item }} has unsafe password state
{{ item.stdout.split()[1] }}.
loop: "{{ litecoin_access_password_states.results }}"
loop_control:
label: "{{ item.item }}"
@@ -0,0 +1,32 @@
#!/bin/bash
# Managed by Ansible role litecoin_access.
# Read-only litecoin-cli wrapper for the ghost-agent account (NOPASSWD sudo).
# Whitelists read-only RPC calls and executes them as the litecoin service
# user so the node-local cookie auth is used. No sending, no wallet unlock.
set -Eeuo pipefail
readonly ALLOWED=(
{% for command in litecoin_access_readonly_commands %} "{{ command }}"
{% endfor %})
if [[ $# -lt 1 ]]; then
printf 'usage: ltc-readonly <command> [args...]\nallowed:' >&2
printf ' %s' "${ALLOWED[@]}" >&2
printf '\n' >&2
exit 2
fi
allowed=0
for candidate in "${ALLOWED[@]}"; do
if [[ "$1" == "$candidate" ]]; then
allowed=1
break
fi
done
if [[ "$allowed" -ne 1 ]]; then
printf 'ltc-readonly: command not allowed: %s\n' "$1" >&2
exit 2
fi
exec /usr/sbin/runuser -u litecoin -- \
/opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf "$@"
@@ -0,0 +1,18 @@
# Managed by Ansible role litecoin_access.
# GNAI-011 SSH baseline. TCP forwarding stays disabled on purpose: the
# Litecoin RPC is reached via `ssh ... ltc-readonly` / `sudo -u litecoin
# litecoin-cli`, never via an SSH tunnel (GNAI-024 Abschnitt 2, Befund d).
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
PubkeyAuthentication yes
AllowUsers {{ litecoin_access_agent_user }} {{ litecoin_access_admin_user }} {{ litecoin_access_deploy_user }}
X11Forwarding no
AllowAgentForwarding no
AllowTcpForwarding no
AllowStreamLocalForwarding no
DisableForwarding yes
PermitTunnel no
MaxAuthTries 3
LoginGraceTime 30
LogLevel VERBOSE
@@ -0,0 +1,16 @@
# litecoin_backup
Daily encrypted wallet backup of CT 114 (GNAI-024 Abschnitt 9):
- `/usr/local/sbin/litecoin-wallet-backup.sh` runs `backupwallet` as the
`litecoin` user into `/var/lib/litecoin/backups/`, then a restic backup of
`backups/` only (never the chain — a restore re-syncs and then restores
`wallet.dat`), then `forget --keep-daily 30 --prune`.
- restic repository: `sftp:gn-backup@10.0.0.90:...` (host-independent backup
target ghostnet-ki) unless the operator overrides
`litecoin_backup_repository` with a separate PBS. Encryption is
client-side (restic default); the target only sees ciphertext.
- Secrets are never managed here: the restic password file and the dedicated
SSH key are placed by the operator into `/etc/litecoin-backup/` (root-only);
the role only pins the target host key and asserts file modes. The timers
run daily 03:00 (backup) and monthly (restic check).
@@ -0,0 +1,24 @@
---
# restic target on the host-independent backup host ghostnet-ki (10.0.0.90),
# account gn-backup; overridden per inventory (a separate PBS in the LAN is
# equally possible — GNAI-024 Abschnitt 2 Befund g).
litecoin_backup_repository: "sftp:gn-backup@10.0.0.90:/var/lib/ghostnet-ai-backup/ct114/restic"
litecoin_backup_keep_daily: 30
litecoin_backup_env_dir: /etc/litecoin-backup
litecoin_backup_password_file: "{{ litecoin_backup_env_dir }}/restic-password"
# Default ssh identity name so restic's sftp backend picks it up via HOME.
litecoin_backup_ssh_key: "{{ litecoin_backup_env_dir }}/.ssh/id_ed25519"
litecoin_backup_known_hosts: "{{ litecoin_backup_env_dir }}/.ssh/known_hosts"
# ghostnet-ki host key (ed25519), same pin as pve_lxc_backup_sync.
litecoin_backup_target_host: 10.0.0.90
litecoin_backup_target_host_key_ed25519: >-
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID1UMrhG0WoKlRfadNadWdZogijlhjCz8uXfWbjvxuf8
litecoin_backup_script: /usr/local/sbin/litecoin-wallet-backup.sh
litecoin_backup_service: litecoin-wallet-backup.service
litecoin_backup_timer: litecoin-wallet-backup.timer
litecoin_backup_timer_oncalendar: '*-*-* 03:00:00'
litecoin_restic_check_timer: litecoin-restic-check.timer
litecoin_restic_check_oncalendar: '*-*-01 04:00:00'
litecoin_backup_wallet_dir: /var/lib/litecoin/backups
litecoin_backup_logrotate: /etc/logrotate.d/litecoin-backup
@@ -0,0 +1,4 @@
---
- name: Reload systemd for litecoin backup
ansible.builtin.systemd_service:
daemon_reload: true
@@ -0,0 +1,116 @@
---
- name: Create the protected restic environment directory
ansible.builtin.file:
path: "{{ litecoin_backup_env_dir }}"
state: directory
owner: root
group: root
mode: "0700"
- name: Create the root-only ssh directory for the restic key
ansible.builtin.file:
path: "{{ litecoin_backup_env_dir }}/.ssh"
state: directory
owner: root
group: root
mode: "0700"
- name: Pin the backup target host key for restic's sftp backend
ansible.builtin.lineinfile:
path: "{{ litecoin_backup_known_hosts }}"
regexp: '^10\.0\.0\.90 ssh-ed25519 '
line: "10.0.0.90 {{ litecoin_backup_target_host_key_ed25519 }}"
owner: root
group: root
mode: "0600"
create: true
- name: Require the operator-provided restic SSH key
ansible.builtin.stat:
path: "{{ litecoin_backup_ssh_key }}"
register: litecoin_backup_ssh_key_stat
- name: Fail with a clear message when the restic SSH key is missing
ansible.builtin.fail:
msg: >-
{{ litecoin_backup_ssh_key }} is missing. The operator creates the
dedicated CT 114 backup key, authorizes it for gn-backup on
ghostnet-ki (source-restricted to 10.0.0.61) and installs the private
key here with mode 0600; the public key never enters the repository
(GNAI-024 Abschnitt 6 Schritt 0).
when: not litecoin_backup_ssh_key_stat.stat.exists
- name: Verify the restic SSH key permissions
ansible.builtin.stat:
path: "{{ litecoin_backup_ssh_key }}"
register: litecoin_backup_ssh_key_mode
- name: Assert the restic SSH key is root-only
ansible.builtin.assert:
that:
- litecoin_backup_ssh_key_mode.stat.mode == "0600"
- litecoin_backup_ssh_key_mode.stat.pw_name == "root"
fail_msg: "{{ litecoin_backup_ssh_key }} must be root:root 0600."
- name: Install the daily wallet backup script
ansible.builtin.template:
src: litecoin-wallet-backup.sh.j2
dest: "{{ litecoin_backup_script }}"
owner: root
group: root
mode: "0750"
validate: /bin/bash -n %s
- name: Install the wallet backup systemd service
ansible.builtin.template:
src: litecoin-wallet-backup.service.j2
dest: "/etc/systemd/system/{{ litecoin_backup_service }}"
owner: root
group: root
mode: "0644"
notify: Reload systemd for litecoin backup
- name: Install the daily wallet backup timer
ansible.builtin.template:
src: litecoin-wallet-backup.timer.j2
dest: "/etc/systemd/system/{{ litecoin_backup_timer }}"
owner: root
group: root
mode: "0644"
notify: Reload systemd for litecoin backup
- name: Install the monthly restic check service
ansible.builtin.template:
src: litecoin-restic-check.service.j2
dest: /etc/systemd/system/litecoin-restic-check.service
owner: root
group: root
mode: "0644"
notify: Reload systemd for litecoin backup
- name: Install the monthly restic check timer
ansible.builtin.template:
src: litecoin-restic-check.timer.j2
dest: "/etc/systemd/system/{{ litecoin_restic_check_timer }}"
owner: root
group: root
mode: "0644"
notify: Reload systemd for litecoin backup
- name: Install the backup log logrotate policy
ansible.builtin.template:
src: litecoin-backup.logrotate.j2
dest: "{{ litecoin_backup_logrotate }}"
owner: root
group: root
mode: "0644"
- name: Enable the backup timers
ansible.builtin.systemd_service:
name: "{{ item }}"
enabled: true
state: started
daemon_reload: true
loop:
- "{{ litecoin_backup_timer }}"
- "{{ litecoin_restic_check_timer }}"
@@ -0,0 +1,8 @@
/var/log/litecoin-backup.log {
weekly
rotate 8
compress
missingok
notifempty
copytruncate
}
@@ -0,0 +1,11 @@
[Unit]
Description=Monthly restic check of the Litecoin wallet backup repository
[Service]
Type=oneshot
Environment=RESTIC_REPOSITORY={{ litecoin_backup_repository }}
Environment=RESTIC_PASSWORD_FILE={{ litecoin_backup_password_file }}
Environment=HOME={{ litecoin_backup_env_dir }}
Environment=SSH_AUTH_SOCK=
ExecStart=/usr/bin/restic check --read-data-subset=5%
Nice=10
@@ -0,0 +1,9 @@
[Unit]
Description=Monthly restic repository check for the Litecoin wallet backups
[Timer]
OnCalendar={{ litecoin_restic_check_oncalendar }}
Persistent=true
[Install]
WantedBy=timers.target
@@ -0,0 +1,11 @@
[Unit]
Description=Encrypted Litecoin wallet backup to the off-host restic repository
After=litecoind.service
[Service]
Type=oneshot
ExecStart={{ litecoin_backup_script }}
# SSH key for the restic sftp target, root-only.
Environment=HOME={{ litecoin_backup_env_dir }}
Environment=SSH_AUTH_SOCK=
Nice=10
@@ -0,0 +1,26 @@
#!/bin/bash
# Managed by Ansible role litecoin_backup.
# Daily wallet backup: backupwallet as the litecoin user, then a
# client-side encrypted restic backup of backups/ only (never the chain —
# a restore re-syncs the chain and then restores wallet.dat). Secrets stay
# in {{ litecoin_backup_password_file }} (root-only) and the dedicated SSH key;
# nothing is written to logs or the repository.
set -Eeuo pipefail
export RESTIC_REPOSITORY="{{ litecoin_backup_repository }}"
export RESTIC_PASSWORD_FILE="{{ litecoin_backup_password_file }}"
backup_dir="{{ litecoin_backup_wallet_dir }}"
today="$(date +%F)"
/usr/sbin/runuser -u litecoin -- \
/opt/litecoin/bin/litecoin-cli -conf=/etc/litecoin/litecoin.conf \
backupwallet "${backup_dir}/wallet-${today}"
/usr/bin/restic -r "$RESTIC_REPOSITORY" \
--password-file "$RESTIC_PASSWORD_FILE" \
backup "$backup_dir"
/usr/bin/restic -r "$RESTIC_REPOSITORY" \
--password-file "$RESTIC_PASSWORD_FILE" \
forget --keep-daily {{ litecoin_backup_keep_daily }} --prune
@@ -0,0 +1,9 @@
[Unit]
Description=Daily encrypted Litecoin wallet backup (03:00)
[Timer]
OnCalendar={{ litecoin_backup_timer_oncalendar }}
Persistent=true
[Install]
WantedBy=timers.target
@@ -0,0 +1,16 @@
# litecoin_core
Installs the pinned Litecoin Core release into `/opt/litecoin-<version>` with
a stable `/opt/litecoin` symlink. The tarball is fetched over HTTPS from
`download.litecoin.org` and verified fail-closed against the pinned SHA-256
from the signed `SHA256SUMS.asc` (v0.21.5.8, see GNAI-024 Abschnitt 2 Befund
a); the role then asserts `litecoind --version`.
`litecoin.conf` is Tor-only (`proxy=127.0.0.1:9050`, `onlynet=onion`,
`listen=0`, no seeds/UPNP/NAT-PMP), RPC on `127.0.0.1:9332` with cookie auth
(no `rpcpassword`, no `rpcauth` material in any file — the node is only ever
administered as the `litecoin` user over SSH exec, GNAI-024 Befund d/e).
`litecoind.service` runs as `litecoin` with systemd hardening; the service is
enabled and started only when the inventory sets
`litecoin_service_start_allowed: true` (production). debug.log is rotated
weekly (copytruncate).
@@ -0,0 +1,27 @@
---
litecoin_core_version: 0.21.5.8
litecoin_core_tarball_name: "litecoin-{{ litecoin_core_version }}-x86_64-linux-gnu.tar.gz"
litecoin_core_base_url: "https://download.litecoin.org/litecoin-{{ litecoin_core_version }}/linux"
# SHA-256 from the signed SHA256SUMS.asc (GNAI-024 Abschnitt 2 Befund a).
litecoin_core_tarball_sha256: >-
43200c9f9d65ebc126ea5833ca9429e144c4b3273da6bb9f4e89fd7450ab1be9
litecoin_core_install_root: /opt
litecoin_core_versioned_dir: "{{ litecoin_core_install_root }}/litecoin-{{ litecoin_core_version }}"
litecoin_core_symlink: "{{ litecoin_core_install_root }}/litecoin"
litecoin_core_download_dir: /usr/local/src/litecoin
litecoin_core_user: litecoin
litecoin_core_group: litecoin
litecoin_core_datadir: /var/lib/litecoin
litecoin_core_config_dir: /etc/litecoin
litecoin_core_config: "{{ litecoin_core_config_dir }}/litecoin.conf"
# Litecoin mainnet: P2P 9333, RPC 9332 (GNAI-024 Befund c: 8332 ist Bitcoin).
litecoin_core_rpc_port: 9332
litecoin_core_tor_socks: 127.0.0.1:9050
litecoin_core_dbcache_mb: 2048
litecoin_core_fallbackfee: 0.0001
litecoin_core_service_name: litecoind.service
litecoin_core_logrotate: /etc/logrotate.d/litecoin
@@ -0,0 +1,9 @@
---
- name: Reload systemd for litecoind
ansible.builtin.systemd_service:
daemon_reload: true
- name: Restart litecoind
ansible.builtin.systemd_service:
name: litecoind.service
state: restarted
@@ -0,0 +1,91 @@
---
- name: Require the pinned Litecoin Core tarball checksum
ansible.builtin.assert:
that:
- litecoin_core_tarball_sha256 is match('^[0-9a-f]{64}$')
- litecoin_core_version is match('^0\\.21\\.5\\.[0-9]+$')
fail_msg: >-
litecoin_core_tarball_sha256 must be a pinned 64-hex SHA-256 from the
signed SHA256SUMS.asc and the version must be in the audited 0.21.5.x
series (GNAI-024 Abschnitt 2 Befund a).
- name: Download the pinned Litecoin Core release tarball
ansible.builtin.get_url:
url: "{{ litecoin_core_base_url }}/{{ litecoin_core_tarball_name }}"
dest: "{{ litecoin_core_download_dir }}/{{ litecoin_core_tarball_name }}"
checksum: "sha256:{{ litecoin_core_tarball_sha256 }}"
mode: "0644"
owner: root
group: root
timeout: 300
- name: Extract the verified Litecoin Core release
ansible.builtin.unarchive:
src: "{{ litecoin_core_download_dir }}/{{ litecoin_core_tarball_name }}"
dest: "{{ litecoin_core_install_root }}"
remote_src: true
creates: "{{ litecoin_core_versioned_dir }}/bin/litecoind"
- name: Point the stable symlink at the verified version
ansible.builtin.file:
src: "{{ litecoin_core_versioned_dir }}"
dest: "{{ litecoin_core_symlink }}"
state: link
owner: root
group: root
- name: Verify the installed litecoind binary
ansible.builtin.command:
argv:
- "{{ litecoin_core_symlink }}/bin/litecoind"
- --version
check_mode: false
changed_when: false
register: litecoin_core_version_output
- name: Assert the expected Litecoin Core version
ansible.builtin.assert:
that:
- "('Litecoin Core version v' ~ litecoin_core_version) in litecoin_core_version_output.stdout"
fail_msg: "Unexpected litecoind version: {{ litecoin_core_version_output.stdout }}"
- name: Install the managed litecoin.conf
ansible.builtin.template:
src: litecoin.conf.j2
dest: "{{ litecoin_core_config }}"
owner: root
group: "{{ litecoin_core_group }}"
mode: "0640"
notify: Restart litecoind
- name: Install the hardened litecoind systemd unit
ansible.builtin.template:
src: litecoind.service.j2
dest: "/etc/systemd/system/{{ litecoin_core_service_name }}"
owner: root
group: root
mode: "0644"
notify:
- Reload systemd for litecoind
- Restart litecoind
- name: Install the litecoin debug.log logrotate policy
ansible.builtin.template:
src: litecoin.logrotate.j2
dest: "{{ litecoin_core_logrotate }}"
owner: root
group: root
mode: "0644"
- name: Enable litecoind without starting it yet
ansible.builtin.systemd_service:
name: "{{ litecoin_core_service_name }}"
enabled: true
state: "{{ 'started' if litecoin_service_start_allowed | bool else 'stopped' }}"
daemon_reload: true
- name: Start litecoind when the inventory allows it
ansible.builtin.systemd_service:
name: "{{ litecoin_core_service_name }}"
state: started
when: litecoin_service_start_allowed | bool
@@ -0,0 +1,30 @@
# Managed by Ansible role litecoin_core. No credentials in this file:
# RPC is cookie-authenticated and bound to loopback only (GNAI-024 Befund d/e).
# --- Network: Tor only, no clearnet, no inbound ---
proxy={{ litecoin_core_tor_socks }}
onlynet=onion
listen=0
discover=0
dnsseed=0
fixedseeds=0
upnp=0
natpmp=0
# --- RPC: loopback only, cookie auth, no stored credentials ---
server=1
rpcbind=127.0.0.1
rpcallowip=127.0.0.1
rpcport={{ litecoin_core_rpc_port }}
rpcthreads=4
# --- Chain / wallet ---
datadir={{ litecoin_core_datadir }}
dbcache={{ litecoin_core_dbcache_mb }}
txindex=0
wallet=cold
fallbackfee={{ litecoin_core_fallbackfee }}
# MWEB stays usable locally, but addresses handed to exchanges or services
# (Bitpanda, Rapidgator) must always be legacy/bech32, never ltcmweb1...
# (GNAI-024 Abschnitt 2 Befund f).
prune=0
@@ -0,0 +1,8 @@
{{ litecoin_core_datadir }}/debug.log {
weekly
rotate 4
compress
missingok
notifempty
copytruncate
}
@@ -0,0 +1,34 @@
[Unit]
Description=Litecoin Core full node (Tor-only cold wallet)
After=network-online.target tor.service
Wants=network-online.target
[Service]
Type=simple
User={{ litecoin_core_user }}
Group={{ litecoin_core_group }}
ExecStart={{ litecoin_core_symlink }}/bin/litecoind -conf={{ litecoin_core_config }} -datadir={{ litecoin_core_datadir }}
Restart=on-failure
RestartSec=30
TimeoutStopSec=120
KillSignal=SIGINT
# Hardening
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
PrivateTmp=true
PrivateDevices=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
RestrictNamespaces=true
LockPersonality=true
MemoryDenyWriteExecute=true
CapabilityBoundingSet=
AmbientCapabilities=
ReadWritePaths={{ litecoin_core_datadir }}
[Install]
WantedBy=multi-user.target
@@ -0,0 +1,7 @@
# litecoin_fail2ban
Native fail2ban (apt, no Podman on CT 114) with the sshd jail on the systemd
backend (Debian 13 LXC has no rsyslog), banning via `nftables-multiport`.
Management networks (LAN, WireGuard) are on `ignoreip`; the jail is verified
with `fail2ban-client status sshd`. Mirrors the CT 103 fail2ban abnahme
without the NPM-specific jails.
@@ -0,0 +1,7 @@
---
litecoin_fail2ban_jail_dropin: /etc/fail2ban/jail.d/00-ghostnet-litecoin.conf
litecoin_fail2ban_bantime: 1h
litecoin_fail2ban_findtime: 10m
litecoin_fail2ban_maxretry: 3
# Management networks are trusted; only brute force from elsewhere is banned.
litecoin_fail2ban_ignoreip: 127.0.0.1/8 10.0.0.0/24 10.8.0.0/24
@@ -0,0 +1,5 @@
---
- name: Restart fail2ban
ansible.builtin.systemd_service:
name: fail2ban.service
state: restarted
@@ -0,0 +1,33 @@
---
- name: Install the Ghostnet fail2ban jail drop-in
ansible.builtin.template:
src: jail.local.j2
dest: "{{ litecoin_fail2ban_jail_dropin }}"
owner: root
group: root
mode: "0644"
notify: Restart fail2ban
- name: Enable and start fail2ban
ansible.builtin.systemd_service:
name: fail2ban.service
enabled: true
state: started
- name: Read the fail2ban sshd jail status
ansible.builtin.command:
argv:
- /usr/bin/fail2ban-client
- status
- sshd
check_mode: false
changed_when: false
register: litecoin_fail2ban_sshd_status
when: not ansible_check_mode
- name: Verify the sshd jail is active
ansible.builtin.assert:
that:
- litecoin_fail2ban_sshd_status.stdout is search('Status')
- litecoin_fail2ban_sshd_status.stdout is search('Jail list:.*sshd')
when: not ansible_check_mode
@@ -0,0 +1,15 @@
# Managed by Ansible role litecoin_fail2ban.
# Debian 13 has no rsyslog in the LXC; the sshd jail reads the journal.
[DEFAULT]
backend = systemd
bantime = {{ litecoin_fail2ban_bantime }}
findtime = {{ litecoin_fail2ban_findtime }}
maxretry = {{ litecoin_fail2ban_maxretry }}
ignoreip = {{ litecoin_fail2ban_ignoreip }}
action = nftables-multiport[port="ssh", protocol=tcp]
[sshd]
enabled = true
port = ssh
logpath = %(sshd_log)s
backend = systemd
@@ -0,0 +1,9 @@
# litecoin_firewall
Native nftables policy for CT 114 (repo convention: nftables, not ufw —
GNAI-024 Abschnitt 2 Befund b): `inet ghostnet_filter` with default-deny
input, loopback and established traffic accepted, ICMP diagnostics, SSH (TCP
22) only from the management networks (`10.0.0.0/24`, `10.8.0.0/24`), output
accepted (the Tor client needs outbound), forward dropped. No port of
litecoind (P2P 9333, RPC 9332) is ever opened; the service override destroys
only the Ghostnet-owned table on service stop.
@@ -0,0 +1,5 @@
---
litecoin_firewall_management_ipv4:
- 10.0.0.0/24
- 10.8.0.0/24
litecoin_firewall_ssh_port: 22
@@ -0,0 +1,9 @@
---
- name: Reload systemd for the Litecoin firewall
ansible.builtin.systemd_service:
daemon_reload: true
- name: Restart the Litecoin firewall
ansible.builtin.systemd_service:
name: nftables.service
state: restarted
@@ -0,0 +1,93 @@
---
- name: Require a non-empty management allowlist
ansible.builtin.assert:
that:
- litecoin_firewall_management_ipv4 | length > 0
fail_msg: The firewall management allowlist must be explicit and non-empty.
- name: Read the active Ansible SSH transport endpoints
become: false
ansible.builtin.command:
argv:
- /usr/bin/printenv
- SSH_CONNECTION
check_mode: false
changed_when: false
register: litecoin_firewall_ssh_connection
- name: Require the active Ansible SSH source in the management allowlist
ansible.builtin.command:
argv: >-
{{
[
'/usr/bin/python3',
'-c',
'import ipaddress,sys; address=ipaddress.ip_address(sys.argv[1]); raise SystemExit(0 if any(address in ipaddress.ip_network(network) for network in sys.argv[2:]) else 1)',
litecoin_firewall_ssh_connection.stdout.split()[0]
] + litecoin_firewall_management_ipv4
}}
check_mode: false
changed_when: false
vars:
ansible_command_timeout: 5
- name: Create the nftables service override directory
ansible.builtin.file:
path: /etc/systemd/system/nftables.service.d
state: directory
owner: root
group: root
mode: "0755"
- name: Install the scoped nftables stop override
ansible.builtin.template:
src: nftables.service-override.conf.j2
dest: /etc/systemd/system/nftables.service.d/10-ghostnet-preserve.conf
owner: root
group: root
mode: "0644"
notify:
- Reload systemd for the Litecoin firewall
- Restart the Litecoin firewall
- name: Install and validate the Litecoin nftables policy
ansible.builtin.template:
src: nftables.conf.j2
dest: /etc/nftables.conf
owner: root
group: root
mode: "0750"
validate: /usr/sbin/nft --check --file %s
notify: Restart the Litecoin firewall
- name: Flush firewall handlers before verification
ansible.builtin.meta: flush_handlers
- name: Enable and start the nftables service
ansible.builtin.systemd_service:
name: nftables.service
enabled: true
state: started
daemon_reload: true
- name: Read the active Ghostnet nftables table
ansible.builtin.command:
argv:
- /usr/sbin/nft
- list
- table
- inet
- ghostnet_filter
check_mode: false
changed_when: false
register: litecoin_firewall_active_table
when: not ansible_check_mode
- name: Verify the active firewall policy
ansible.builtin.assert:
that:
- litecoin_firewall_active_table.stdout is search('policy drop')
- litecoin_firewall_active_table.stdout is search('SSH management')
- litecoin_firewall_active_table.stdout is search('default input deny')
- litecoin_firewall_active_table.stdout is search('CT 114 forwards nothing')
when: not ansible_check_mode
@@ -0,0 +1,43 @@
#!/usr/sbin/nft -f
# Managed by Ansible role litecoin_firewall.
# CT 114 runs no public service: default-deny input, SSH from the management
# networks only, no P2P (9333) and no RPC (9332) listener exposed. The node
# reaches the Litecoin network exclusively as a Tor client (outbound only).
destroy table inet ghostnet_filter
table inet ghostnet_filter {
set management_ipv4 {
type ipv4_addr
flags interval
elements = { {{ litecoin_firewall_management_ipv4 | join(', ') }} }
}
chain input {
type filter hook input priority 10; policy drop;
iifname "lo" counter accept comment "local loopback"
ct state established,related counter accept
ct state invalid counter drop
meta l4proto icmp counter accept comment "IPv4 diagnostics"
meta l4proto ipv6-icmp counter accept comment "IPv6 neighbor discovery"
ip saddr @management_ipv4 tcp dport {{ litecoin_firewall_ssh_port }} ct state new counter accept comment "SSH management"
counter drop comment "default input deny"
}
chain forward {
type filter hook forward priority 10; policy drop;
ct state invalid counter drop
counter drop comment "CT 114 forwards nothing"
}
chain output {
type filter hook output priority 10; policy accept;
}
}
{{ '' }}
@@ -0,0 +1,6 @@
[Service]
# Keep the Ghostnet table across service stops; only the owned table is
# destroyed so a restart does not leave the host unfiltered.
ExecStop=
ExecStop=/usr/sbin/nft destroy table inet ghostnet_filter
{{ '\n' }}
@@ -0,0 +1,11 @@
# litecoin_lxc_baseline
Baseline role for CT 114 (`ltc-node`, 10.0.0.61): identity assertion against
the inventory safeguards, base packages (incl. `tor`, `fail2ban`, `restic`,
`unattended-upgrades`), the locked `litecoin` service account (UID/GID 1100,
`nologin`, no supplementary groups), timezone `Europe/Berlin`, protected
directories and security-only unattended-upgrades. Mirrors
`keycloak_lxc_baseline` / `dns_lxc_baseline`.
The role never installs keys, secrets or application state; that belongs to
`litecoin_access`, `litecoin_core` and `litecoin_backup`.
@@ -0,0 +1,45 @@
---
litecoin_lxc_baseline_timezone: Europe/Berlin
litecoin_lxc_baseline_packages:
- ca-certificates
- curl
- fail2ban
- gnupg
- logrotate
- nftables
- openssh-server
- python3
- restic
- sudo
- tor
- unattended-upgrades
litecoin_lxc_baseline_directories:
- path: /etc/litecoin
owner: root
group: litecoin
mode: "0750"
- path: /etc/litecoin-backup
owner: root
group: root
mode: "0700"
- path: /opt/litecoin
owner: root
group: root
mode: "0755"
- path: /usr/local/src/litecoin
owner: root
group: root
mode: "0700"
- path: /var/lib/litecoin
owner: litecoin
group: litecoin
mode: "0700"
- path: /var/lib/litecoin/backups
owner: litecoin
group: litecoin
mode: "0700"
litecoin_lxc_baseline_unattended_upgrades_allowed_origins: >-
Debian:${distro_codename} ${distro_codename}-security
@@ -0,0 +1,96 @@
---
- name: Verify the Litecoin LXC identity before changing baseline state
ansible.builtin.assert:
that:
- ansible_facts["hostname"] == litecoin_lxc_baseline_expected_hostname
- >-
ansible_facts["distribution"] ==
litecoin_lxc_baseline_expected_distribution
- >-
ansible_facts["distribution_major_version"] ==
litecoin_lxc_baseline_expected_distribution_major_version
- >-
ansible_facts["default_ipv4"]["address"] ==
litecoin_lxc_baseline_expected_ipv4
- >-
ansible_facts["virtualization_type"] ==
litecoin_lxc_baseline_expected_virtualization_type
- ansible_facts["virtualization_role"] == "guest"
- ansible_facts["service_mgr"] == "systemd"
fail_msg: >-
The connected system is not the declared CT 114 Litecoin LXC. No
baseline changes may be applied.
- name: Install baseline administration packages
ansible.builtin.apt:
name: "{{ litecoin_lxc_baseline_packages }}"
state: present
update_cache: true
cache_valid_time: 3600
install_recommends: false
- name: Create the fixed primary group for the Litecoin service account
ansible.builtin.group:
name: litecoin
gid: 1100
state: present
system: true
- name: Create the locked Litecoin service account without login shell
ansible.builtin.user:
name: litecoin
uid: 1100
group: litecoin
home: /var/lib/litecoin
shell: /usr/sbin/nologin
create_home: false
state: present
system: true
password_lock: true
- name: Set the local timezone database link
ansible.builtin.file:
src: "/usr/share/zoneinfo/{{ litecoin_lxc_baseline_timezone }}"
dest: /etc/localtime
state: link
owner: root
group: root
force: true
- name: Record the configured timezone
ansible.builtin.copy:
content: "{{ litecoin_lxc_baseline_timezone }}\n"
dest: /etc/timezone
owner: root
group: root
mode: "0644"
- name: Create protected Litecoin configuration and data paths
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
owner: "{{ item.owner }}"
group: "{{ item.group }}"
mode: "{{ item.mode }}"
loop: "{{ litecoin_lxc_baseline_directories }}"
loop_control:
label: "{{ item.path }}"
- name: Enable and start the unattended-upgrades service (CT 100/102 convention)
ansible.builtin.systemd_service:
name: unattended-upgrades.service
enabled: true
state: started
- name: Restrict unattended-upgrades to Debian security origins
ansible.builtin.copy:
content: |-
Unattended-Upgrade::Origins-Pattern {
"origin=Debian,codename=${distro_codename},label=Debian-Security";
};
Unattended-Upgrade::AutoFixInterruptedDpkg "true";
Unattended-Upgrade::Remove-Unused-Dependencies "true";
dest: /etc/apt/apt.conf.d/52ghostnet-unattended-upgrades
owner: root
group: root
mode: "0644"
@@ -0,0 +1,8 @@
# litecoin_tor
Local-only Tor client in CT 114. `tor` runs as `debian-tor`, client-only
(`ClientOnly 1`, no OR/Dir/Exit), SOCKS on `127.0.0.1:9050` and ControlPort
on `127.0.0.1:9051`, both loopback-only. `litecoind` is configured with
`proxy=127.0.0.1:9050` and `onlynet=onion`, so all P2P traffic leaves via
Tor and the node accepts no inbound connections (`listen=0`). The role
waits for the SOCKS port and reports the bootstrap phase.
@@ -0,0 +1,6 @@
---
litecoin_tor_socks_port: 127.0.0.1:9050
litecoin_tor_control_port: 127.0.0.1:9051
litecoin_tor_data_directory: /var/lib/tor
litecoin_tor_config: /etc/tor/torrc
litecoin_tor_log: /var/log/tor/notices.log
@@ -0,0 +1,5 @@
---
- name: Restart tor
ansible.builtin.systemd_service:
name: tor.service
state: restarted
@@ -0,0 +1,56 @@
---
- name: Create the tor runtime directory
ansible.builtin.file:
path: /run/tor
state: directory
owner: debian-tor
group: debian-tor
mode: "0750"
- name: Install the managed Tor client configuration
ansible.builtin.template:
src: torrc.j2
dest: "{{ litecoin_tor_config }}"
owner: debian-tor
group: debian-tor
mode: "0640"
validate: /usr/bin/tor --verify-config -f %s
notify: Restart tor
- name: Create the tor log directory
ansible.builtin.file:
path: /var/log/tor
state: directory
owner: debian-tor
group: debian-tor
mode: "0750"
- name: Enable and start the Tor client service
ansible.builtin.systemd_service:
name: tor.service
enabled: true
state: started
- name: Wait for the Tor SOCKS port on loopback
ansible.builtin.wait_for:
host: 127.0.0.1
port: 9050
timeout: 120
when: not ansible_check_mode
- name: Read the Tor bootstrap status
ansible.builtin.command:
argv:
- /usr/bin/torctl
- --socket /run/tor/control
- getinfo
- status/bootstrap-phase
check_mode: false
changed_when: false
register: litecoin_tor_bootstrap
when: not ansible_check_mode
- name: Report the Tor bootstrap phase
ansible.builtin.debug:
msg: "{{ litecoin_tor_bootstrap.stdout | default('check mode: skipped') }}"
when: not ansible_check_mode
@@ -0,0 +1,19 @@
# Managed by Ansible role litecoin_tor.
# Local-only Tor client for litecoind: SOCKS on loopback, no public relay,
# no directory service exposure beyond what a client needs.
SocksPort {{ litecoin_tor_socks_port }}
ControlPort {{ litecoin_tor_control_port }}
DataDirectory {{ litecoin_tor_data_directory }}
CacheDirectory {{ litecoin_tor_data_directory }}
PidFile /run/tor/tor.pid
Log notice file {{ litecoin_tor_log }}
RunAsDaemon 0
User debian-tor
# Client only: never act as relay, bridge or onion service host.
ClientOnly 1
ORPort 0
DirPort 0
ExitPolicy reject *:*
# Keep bootstrap deterministic; litecoind uses onlynet=onion.
AssumeReachable 0
NumEntryGuards 4
@@ -0,0 +1,116 @@
# Proxmox automation — CT 114 Litecoin wallet
Reviewed host-side helpers for the reproducible creation of CT 114
(`ltc-node`, `10.0.0.61`). They contain no password and no private key.
## CT 114 provisioning profile
| Setting | CT 114 value |
| --- | --- |
| CT ID / hostname | `114` / `ltc-node` |
| OS | Debian 13, amd64 |
| Container type | unprivileged LXC, **no nesting** (litecoind is a plain systemd service, no Podman) |
| CPU | 2 cores |
| Memory | 4096 MiB |
| Swap | 1024 MiB (set via `pct set` after creation, as with CT 102) |
| Root disk | 150 GiB on `local-lvm` (thin-provisioned, snapshot-capable; chain ~100 GiB + growth) |
| Network | `vmbr0`, `10.0.0.61/24`, gateway `10.0.0.1`, DNS `10.0.0.14` (Pi-hole), IPv6 disabled |
| Boot / protection | start on boot, protection enabled |
| Time zone | `Europe/Berlin` |
| Initial root SSH | not required; the hook installs and hardens OpenSSH |
| Post-install hook | `/usr/local/sbin/ghostnet-litecoin-ansible-bootstrap-hook.sh` |
`10.0.0.61` is inside the static server range (up to `.99`, GNAI-007
Adressplan) and was free in the documented inventory; the DHCP client range
starts at `.100`.
## Step 0 (workstation, before any PVE step)
The operator generates the three CT 114 key pairs and installs the public
keys:
```bash
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_ghostnet_ct114_ghost -C "ghost@ghostnet-ct114" # interactively, with passphrase
# ghost-agent and ansible-deploy are passphrase-less per AGENTS.md and were
# already generated on 2026-11-25:
# ~/.ssh/id_ed25519_ghostnet_ct114_agent
# ~/.ssh/id_ed25519_ghostnet_ct114_ansible_deploy
cp ~/.ssh/id_ed25519_ghostnet_ct114_*.pub into this repo:
proxmox/lxc/ct-114-litecoin-wallet/ansible/files/ssh/litecoin-ghost.pub
proxmox/lxc/ct-114-litecoin-wallet/ansible/files/ssh/litecoin-ghost-agent.pub
proxmox/lxc/ct-114-litecoin-wallet/ansible/files/ssh/litecoin-ansible-deploy.pub
# then replace the ADMIN_PUBLIC_KEY placeholder in
# ghostnet-litecoin-ansible-bootstrap-hook.sh with the exact line from
# litecoin-ghost.pub, recompute its SHA-256 and update POST_INSTALL_HOOK_SHA256
# in provision-ct114-litecoin.sh.
```
The `ghost` key passphrase is an interactive operator step and is never
written down anywhere (AGENTS.md: operator-run secret steps).
## Step 1 — install the reviewed hooks on the PVE host (operator, root@pve)
```bash
install -o root -g root -m 0750 \
proxmox/shared/scripts/ghostnet-lxc-baseline.sh \
/usr/local/sbin/ghostnet-lxc-baseline.sh
install -o root -g root -m 0700 \
proxmox/lxc/ct-114-litecoin-wallet/scripts/ghostnet-litecoin-ansible-bootstrap-hook.sh \
/usr/local/sbin/ghostnet-litecoin-ansible-bootstrap-hook.sh
sha256sum /usr/local/sbin/ghostnet-lxc-baseline.sh /usr/local/sbin/ghostnet-litecoin-ansible-bootstrap-hook.sh
# compare with BASELINE_HOOK_SHA256 / POST_INSTALL_HOOK_SHA256 in
# provision-ct114-litecoin.sh (baseline pin: 111f1b70…381b10, audited for CT 102)
```
## Step 2 — create the container (operator, root@pve)
```bash
install -o root -g root -m 0700 \
proxmox/lxc/ct-114-litecoin-wallet/scripts/provision-ct114-litecoin.sh \
/usr/local/sbin/provision-ct114-litecoin.sh
/usr/local/sbin/provision-ct114-litecoin.sh
```
The launcher pins the Community Scripts `ProxmoxVE` and `core` repositories
to the revisions audited on 2026-11-25 (`c0c9d93d…`, `d1cec878…`), verifies
the downloaded `ct/debian.sh` by SHA-256
(`8396340f…86187d`), requires free capacity on `local-lvm`, names every
material CT setting explicitly, rejects an occupied CT ID, and never deletes
or replaces an existing container. After Community Scripts returns it sets
1024 MiB swap and verifies the complete PVE configuration, the hook log and
the guest account state.
## `ghostnet-litecoin-ansible-bootstrap-hook.sh`
CT-114-specific Community Scripts post-install hook. It calls the generic
baseline hook (`ghostnet-lxc-baseline.sh`) and then establishes only the
transport and privilege boundary needed by Ansible:
- it refuses any CT ID other than 114, any helper application other than
Debian, a hostname other than `ltc-node`, or a guest without `10.0.0.61`;
- it creates or validates `ghost-agent` 1000:1000, `ghost` 1001:1001 and
`ansible-deploy` 1002:1002;
- it installs the three role-specific public keys, limited to
`10.0.0.0/24,10.8.0.0/24`; the embedded keys must remain identical to
`../ansible/files/ssh/litecoin-{ghost-agent,ghost,ansible-deploy}.pub`;
- it keeps `ghost-agent` and `ansible-deploy` passwords locked, grants only
`ansible-deploy` reviewed `NOPASSWD: ALL`, and leaves `ghost` on Debian's
password-gated `sudo` policy;
- it disables SSH root/password authentication and TCP forwarding, empties
the temporary root `authorized_keys`, and validates SSH and sudo before
returning success.
The hook does not install Tor, Litecoin Core, nftables, fail2ban or any
wallet state. Those belong to the Ansible roles
([`../ansible/`](../ansible/README.md)).
## After creation
1. Record the SSH host-key fingerprint (`pct exec 114 -- ssh-keygen -lf
/etc/ssh/ssh_host_ed25519_key.pub`) and pin it in all three
`host_vars/litecoin-ct114.yml` files.
2. `pct exec 114 -- passwd ghost` (interactive, operator).
3. If VPN management access is wanted, add `10.0.0.61` to the WireGuard
server-admin target set on CT 105 (GNAI-007) — separate change with its
own tests.
4. Run the Ansible commissioning sequence in [`../ansible/README.md`](../ansible/README.md).
@@ -0,0 +1,277 @@
#!/usr/bin/env bash
set -Eeuo pipefail
umask 077
readonly EXPECTED_CTID="${GHOSTNET_LITECOIN_CTID:-114}"
readonly EXPECTED_HOSTNAME="${GHOSTNET_LITECOIN_HOSTNAME:-ltc-node}"
readonly EXPECTED_IPV4="${GHOSTNET_LITECOIN_IPV4:-10.0.0.61}"
readonly BASELINE_HOOK="${GHOSTNET_BASELINE_HOOK:-/usr/local/sbin/ghostnet-lxc-baseline.sh}"
readonly SSH_SOURCE_NETWORKS="${GHOSTNET_SSH_SOURCE_NETWORKS:-10.0.0.0/24,10.8.0.0/24}"
readonly AGENT_USER="ghost-agent"
readonly AGENT_UID="1000"
readonly ADMIN_USER="ghost"
readonly ADMIN_UID="1001"
readonly DEPLOY_USER="ansible-deploy"
readonly DEPLOY_UID="1002"
# Must stay identical to ../ansible/files/ssh/litecoin-*.pub.
# The ADMIN_PUBLIC_KEY placeholder is replaced with the operator-generated
# ghost public key before the hook is installed on the PVE host
# (GNAI-024 Abschnitt 6 Schritt 0); the hook refuses to run while the
# placeholder is present.
readonly AGENT_PUBLIC_KEY='ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMvQR56yADYULrpThnXROAa8GxKWfb+xcnIVLVDVX6Yy ghost-agent@ghostnet-ct114'
readonly ADMIN_PUBLIC_KEY='@GHOSTNET-CT114-GHOST-PUBLIC-KEY@'
readonly DEPLOY_PUBLIC_KEY='ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILfqlYvqesJK9bhMmfv6tRp5pXPFDu13xmYbV+58fopV ansible-deploy@ghostnet-ct114'
log() {
printf '[ghostnet-litecoin-bootstrap] %s\n' "$*"
}
die() {
printf '[ghostnet-litecoin-bootstrap] ERROR: %s\n' "$*" >&2
exit 1
}
[[ "${EUID}" -eq 0 ]] || die "must run as root on the Proxmox host"
command -v pct >/dev/null 2>&1 || die "pct not found; run this hook on Proxmox"
[[ -x "$BASELINE_HOOK" ]] || die "baseline hook is missing or not executable: ${BASELINE_HOOK}"
[[ "$ADMIN_PUBLIC_KEY" != '@GHOSTNET-CT114-GHOST-PUBLIC-KEY@' ]] ||
die "ADMIN_PUBLIC_KEY placeholder not replaced; see scripts/README.md step 0"
ctid="${CTID:-${1:-}}"
[[ "$ctid" =~ ^[0-9]+$ ]] || die "CTID must be supplied by Community Scripts or as the first argument"
[[ "$ctid" == "$EXPECTED_CTID" ]] || die "refusing CT ${ctid}; expected CT ${EXPECTED_CTID}"
if [[ -n "${APP:-}" ]]; then
[[ "${APP,,}" == "debian" ]] || die "refusing helper application ${APP}; expected Debian"
fi
if [[ -n "${HN:-}" ]]; then
[[ "$HN" == "$EXPECTED_HOSTNAME" ]] || die "refusing helper hostname ${HN}; expected ${EXPECTED_HOSTNAME}"
fi
if [[ -n "${IP:-}" ]]; then
[[ "$IP" == "$EXPECTED_IPV4" || "$IP" == "$EXPECTED_IPV4/"* ]] ||
die "refusing helper IPv4 ${IP}; expected ${EXPECTED_IPV4}"
fi
pct config "$ctid" >/dev/null 2>&1 || die "CT ${ctid} does not exist"
[[ "$(pct status "$ctid")" == 'status: running' ]] || die "CT ${ctid} is not running"
log "running reviewed generic LXC baseline for CT ${ctid}"
CTID="$ctid" "$BASELINE_HOOK" "$ctid"
guest_hostname="$(pct exec "$ctid" -- hostname --short)"
[[ "$guest_hostname" == "$EXPECTED_HOSTNAME" ]] ||
die "guest hostname is ${guest_hostname}; expected ${EXPECTED_HOSTNAME}"
pct exec "$ctid" -- ip -o -4 address show scope global |
grep -Eq "[[:space:]]inet[[:space:]]+${EXPECTED_IPV4//./\\.}/" ||
die "guest does not own expected IPv4 ${EXPECTED_IPV4}"
log "installing deterministic CT 114 access bootstrap"
pct exec "$ctid" -- /bin/bash -s -- \
"$AGENT_USER" "$AGENT_UID" "$ADMIN_USER" "$ADMIN_UID" \
"$DEPLOY_USER" "$DEPLOY_UID" "$SSH_SOURCE_NETWORKS" \
"$AGENT_PUBLIC_KEY" "$ADMIN_PUBLIC_KEY" "$DEPLOY_PUBLIC_KEY" <<'GUEST_SCRIPT'
set -Eeuo pipefail
umask 077
agent_user="$1"
agent_uid="$2"
admin_user="$3"
admin_uid="$4"
deploy_user="$5"
deploy_uid="$6"
ssh_source_networks="$7"
agent_public_key="$8"
admin_public_key="$9"
deploy_public_key="${10}"
log() {
printf '[ghostnet-litecoin-bootstrap/guest] %s\n' "$*"
}
die() {
printf '[ghostnet-litecoin-bootstrap/guest] ERROR: %s\n' "$*" >&2
exit 1
}
[[ "${EUID}" -eq 0 ]] || die "guest stage is not running as root"
validate_existing_user() {
local user="$1"
local expected_uid="$2"
local actual_uid=""
local actual_gid=""
getent passwd "$user" >/dev/null || die "baseline account ${user} is missing"
actual_uid="$(id -u "$user")"
actual_gid="$(id -g "$user")"
[[ "$actual_uid" == "$expected_uid" ]] ||
die "${user} has UID ${actual_uid}; expected ${expected_uid}"
[[ "$actual_gid" == "$expected_uid" ]] ||
die "${user} has GID ${actual_gid}; expected ${expected_uid}"
}
validate_free_identity_slot() {
local user="$1"
local expected_uid="$2"
local owner_match=""
if getent passwd "$user" >/dev/null; then
validate_existing_user "$user" "$expected_uid"
return
fi
getent passwd "$expected_uid" >/dev/null &&
die "UID ${expected_uid} is assigned to $(getent passwd "$expected_uid" | cut -d: -f1)"
getent group "$user" >/dev/null && die "group ${user} exists without its user"
getent group "$expected_uid" >/dev/null &&
die "GID ${expected_uid} is assigned to $(getent group "$expected_uid" | cut -d: -f1)"
owner_match="$(find / -xdev \( -uid "$expected_uid" -o -gid "$expected_uid" \) -print -quit 2>/dev/null || true)"
[[ -z "$owner_match" ]] ||
die "UID/GID ${expected_uid} already owns guest path ${owner_match}"
}
validate_existing_user "$agent_user" "$agent_uid"
validate_existing_user "$admin_user" "$admin_uid"
validate_free_identity_slot "$deploy_user" "$deploy_uid"
if ! getent passwd "$deploy_user" >/dev/null; then
useradd \
--uid "$deploy_uid" \
--create-home \
--shell /bin/bash \
--user-group \
"$deploy_user"
passwd --lock "$deploy_user" >/dev/null
log "created locked ${deploy_user} account with UID/GID ${deploy_uid}"
fi
for user in "$agent_user" "$admin_user" "$deploy_user"; do
[[ "$(getent passwd "$user" | cut -d: -f6)" == "/home/${user}" ]] ||
die "unexpected home directory for ${user}"
[[ "$(getent passwd "$user" | cut -d: -f7)" == "/bin/bash" ]] ||
die "unexpected shell for ${user}"
[[ ! -L "/home/${user}" ]] || die "home for ${user} is a symlink"
[[ ! -L "/home/${user}/.ssh" ]] || die ".ssh for ${user} is a symlink"
[[ ! -L "/home/${user}/.ssh/authorized_keys" ]] ||
die "authorized_keys for ${user} is a symlink"
install -d -o "$user" -g "$user" -m 700 "/home/${user}/.ssh"
done
install_authorized_key() {
local user="$1"
local options="$2"
local public_key="$3"
local target="/home/${user}/.ssh/authorized_keys"
install -o "$user" -g "$user" -m 600 /dev/null "$target"
printf '%s %s\n' "$options" "$public_key" >"$target"
chown "$user:$user" "$target"
chmod 600 "$target"
ssh-keygen -l -f "$target" >/dev/null
}
install_authorized_key \
"$agent_user" \
"restrict,from=\"${ssh_source_networks}\"" \
"$agent_public_key"
install_authorized_key \
"$admin_user" \
"from=\"${ssh_source_networks}\",no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc" \
"$admin_public_key"
install_authorized_key \
"$deploy_user" \
"restrict,from=\"${ssh_source_networks}\"" \
"$deploy_public_key"
passwd --lock "$agent_user" >/dev/null
passwd --lock "$deploy_user" >/dev/null
usermod -aG sudo "$admin_user"
agent_groups="$(id -Gn "$agent_user")"
deploy_groups="$(id -Gn "$deploy_user")"
[[ "$agent_groups" == "$agent_user" ]] ||
die "${agent_user} has unexpected supplementary groups: ${agent_groups}"
[[ "$deploy_groups" == "$deploy_user" ]] ||
die "${deploy_user} has unexpected supplementary groups: ${deploy_groups}"
sudoers_target="/etc/sudoers.d/90-ghostnet-ansible-deploy"
install -o root -g root -m 440 /dev/null "$sudoers_target"
printf '%s ALL=(root) NOPASSWD: ALL\n' "$deploy_user" >"$sudoers_target"
chmod 440 "$sudoers_target"
visudo -cf "$sudoers_target" >/dev/null
ssh_dropin="/etc/ssh/sshd_config.d/00-ghostnet-bootstrap.conf"
install -o root -g root -m 600 /dev/null "$ssh_dropin"
cat >"$ssh_dropin" <<EOF
# Managed by ghostnet-litecoin-ansible-bootstrap-hook.sh.
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
PubkeyAuthentication yes
AllowUsers ${agent_user} ${admin_user} ${deploy_user}
X11Forwarding no
AllowAgentForwarding no
AllowTcpForwarding no
PermitTunnel no
EOF
chmod 600 "$ssh_dropin"
sshd -t
sshd_effective="$(sshd -T)"
grep -qx 'permitrootlogin no' <<<"$sshd_effective" || die "effective PermitRootLogin is not no"
grep -qx 'passwordauthentication no' <<<"$sshd_effective" || die "effective PasswordAuthentication is not no"
grep -qx 'kbdinteractiveauthentication no' <<<"$sshd_effective" || die "effective KbdInteractiveAuthentication is not no"
grep -qx 'pubkeyauthentication yes' <<<"$sshd_effective" || die "effective PubkeyAuthentication is not yes"
effective_allowusers="$({
awk '
$1 == "allowusers" {
for (field = 2; field <= NF; field++) {
print $field
}
}
' <<<"$sshd_effective"
} | LC_ALL=C sort -u)"
expected_allowusers="$(printf '%s\n' "$agent_user" "$admin_user" "$deploy_user" | LC_ALL=C sort)"
[[ "$effective_allowusers" == "$expected_allowusers" ]] ||
die "effective AllowUsers does not match the three managed accounts: ${effective_allowusers//$'\n'/,}"
grep -qx 'allowtcpforwarding no' <<<"$sshd_effective" || die "effective AllowTcpForwarding is not no"
[[ ! -L /root/.ssh ]] || die "root .ssh directory is a symlink"
[[ ! -L /root/.ssh/authorized_keys ]] || die "root authorized_keys is a symlink"
install -d -o root -g root -m 700 /root/.ssh
install -o root -g root -m 600 /dev/null /root/.ssh/authorized_keys
# A restart is intentional. Debian's socket-activated sshd cannot reliably
# rebind port 22 after SIGHUP; the baseline disables ssh.socket first.
systemctl restart ssh.service
systemctl is-active --quiet ssh.service || die "ssh.service is not active after restart"
deploy_sudo_uid="$(runuser -u "$deploy_user" -- sudo -n /usr/bin/id -u)"
[[ "$deploy_sudo_uid" == "0" ]] || die "${deploy_user} non-interactive sudo failed"
if runuser -u "$agent_user" -- sudo -n /usr/bin/true >/dev/null 2>&1; then
die "${agent_user} unexpectedly has non-interactive sudo"
fi
agent_password_state="$(passwd -S "$agent_user" | awk '{print $2}')"
admin_password_state="$(passwd -S "$admin_user" | awk '{print $2}')"
deploy_password_state="$(passwd -S "$deploy_user" | awk '{print $2}')"
[[ "$agent_password_state" == "L" ]] || die "${agent_user} password is not locked"
[[ "$deploy_password_state" == "L" ]] || die "${deploy_user} password is not locked"
[[ "$admin_password_state" == "L" || "$admin_password_state" == "P" ]] ||
die "${admin_user} has unsafe password state ${admin_password_state}"
log "SSH host key: $(ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub)"
log "${agent_user}: $(id "$agent_user") / password ${agent_password_state}"
log "${admin_user}: $(id "$admin_user") / password ${admin_password_state}"
log "${deploy_user}: $(id "$deploy_user") / password ${deploy_password_state}"
log "access bootstrap verified; Ansible may connect after independent host-key validation"
GUEST_SCRIPT
log "CT ${ctid} access bootstrap completed"
log "operator action: set the ${ADMIN_USER} sudo password interactively with 'pct exec ${ctid} -- passwd ${ADMIN_USER}'"
log "do not store that password in this hook, shell history, Ansible inventory, or Git"
@@ -0,0 +1,203 @@
#!/usr/bin/env bash
set -Eeuo pipefail
umask 077
readonly CTID='114'
readonly HOSTNAME='ltc-node'
readonly IPV4_CIDR='10.0.0.61/24'
readonly GATEWAY='10.0.0.1'
readonly NAMESERVER='10.0.0.14'
readonly BRIDGE='vmbr0'
readonly TEMPLATE_STORAGE='local'
readonly CONTAINER_STORAGE='local-lvm'
readonly ROOT_DISK_GIB='150'
readonly POST_INSTALL_HOOK='/usr/local/sbin/ghostnet-litecoin-ansible-bootstrap-hook.sh'
readonly BASELINE_HOOK='/usr/local/sbin/ghostnet-lxc-baseline.sh'
# Audited together on 2026-11-25. Pin both repositories because debian.sh
# loads its execution engine (core/build.func) from community-scripts/core.
readonly PROXMOXVE_COMMIT='c0c9d93d5db1692167efeee2e019f1519af4e0d2'
readonly CORE_COMMIT='d1cec87881d7de053d86434aaf98eb203170c1b9'
readonly DEBIAN_SCRIPT_SHA256='8396340fb3c91142ddf8356eb80904fad181acd6c6ad2c33b22ed4698c86187d'
readonly BASELINE_HOOK_SHA256='111f1b70e47e3a2f6a1bcce22cb0ec50aacd8fbcff37d87fbcf853a318381b10'
# SHA-256 of the hook BEFORE the ADMIN_PUBLIC_KEY placeholder is replaced.
# The operator replaces the placeholder with the generated ghost public key
# (scripts/README.md step 0), recomputes the SHA-256 and updates this pin.
readonly POST_INSTALL_HOOK_SHA256='a742377acdf41020559fe77b1e4313d112338a7221a89259255bbf03bfa359e3'
readonly COMMUNITY_SCRIPTS_URL="https://raw.githubusercontent.com/community-scripts/ProxmoxVE/${PROXMOXVE_COMMIT}"
readonly COMMUNITY_SCRIPTS_CORE_URL="https://raw.githubusercontent.com/community-scripts/core/${CORE_COMMIT}"
readonly DEBIAN_SCRIPT_URL="${COMMUNITY_SCRIPTS_URL}/ct/debian.sh"
log() {
printf '[ghostnet-ct114-provision] %s\n' "$*"
}
die() {
printf '[ghostnet-ct114-provision] ERROR: %s\n' "$*" >&2
exit 1
}
require_command() {
command -v "$1" >/dev/null 2>&1 || die "required command not found: $1"
}
require_file_sha256() {
local expected="$1"
local path="$2"
[[ -f "$path" ]] || die "required file is missing: ${path}"
printf '%s %s\n' "$expected" "$path" | sha256sum --check --status - ||
die "SHA-256 mismatch: ${path}"
}
storage_is_active() {
local storage="$1"
pvesm status | awk -v storage="$storage" '
$1 == storage && $3 == "active" { found = 1 }
END { exit(found ? 0 : 1) }
'
}
storage_has_free() {
local storage="$1"
local required_gib="$2"
pvesm status | awk -v storage="$storage" -v required="$required_gib" '
$1 == storage && $3 == "active" {
avail_kib = $6
if (avail_kib ~ /^[0-9]+$/) {
exit(avail_kib / 1048576 >= required ? 0 : 1)
}
exit 1
}
END { exit 1 }
'
}
[[ "${EUID}" -eq 0 ]] || die 'must run as root on the Proxmox VE host'
for command_name in awk curl grep pct pvesm pveversion sha256sum; do
require_command "$command_name"
done
pveversion >/dev/null 2>&1 || die 'this does not appear to be a Proxmox VE host'
[[ ! -e "/etc/pve/lxc/${CTID}.conf" ]] ||
die "CT ${CTID} still exists; this script never replaces or destroys a container"
if pct status "$CTID" >/dev/null 2>&1; then
die "CT ${CTID} is still registered"
fi
storage_is_active "$TEMPLATE_STORAGE" ||
die "template storage ${TEMPLATE_STORAGE} is not active"
storage_is_active "$CONTAINER_STORAGE" ||
die "container storage ${CONTAINER_STORAGE} is not active"
# The Litecoin chain needs roughly 100 GB plus growth; require headroom for
# the 150 GiB rootfs plus snapshots before creating anything.
storage_has_free "$CONTAINER_STORAGE" $((ROOT_DISK_GIB + 64)) ||
die "container storage ${CONTAINER_STORAGE} has less than $((ROOT_DISK_GIB + 64)) GiB free"
[[ -x "$BASELINE_HOOK" ]] || die "baseline hook is not executable: ${BASELINE_HOOK}"
[[ -x "$POST_INSTALL_HOOK" ]] || die "post-install hook is not executable: ${POST_INSTALL_HOOK}"
require_file_sha256 "$BASELINE_HOOK_SHA256" "$BASELINE_HOOK"
require_file_sha256 "$POST_INSTALL_HOOK_SHA256" "$POST_INSTALL_HOOK"
helper_path="$(mktemp /tmp/ghostnet-debian-helper.XXXXXX.sh)"
cleanup() {
rm -f -- "$helper_path"
}
trap cleanup EXIT
log "downloading pinned Debian helper ${PROXMOXVE_COMMIT}"
curl \
--fail \
--silent \
--show-error \
--location \
--proto '=https' \
--tlsv1.2 \
--retry 3 \
--retry-delay 1 \
--output "$helper_path" \
"$DEBIAN_SCRIPT_URL"
chmod 0700 "$helper_path"
require_file_sha256 "$DEBIAN_SCRIPT_SHA256" "$helper_path"
# These are deliberately explicit even where they currently match upstream
# defaults. This keeps the recorded CT profile stable across future rebuilds.
# No nesting and no keyctl: litecoind runs as a plain systemd service under
# the litecoin user, no Podman is involved.
export COMMUNITY_SCRIPTS_URL COMMUNITY_SCRIPTS_CORE_URL
export mode='generated'
export var_cpu='2'
export var_ram='4096'
export var_disk="$ROOT_DISK_GIB"
export var_ctid="$CTID"
export var_hostname="$HOSTNAME"
export var_os='debian'
export var_version='13'
export var_unprivileged='1'
export var_brg="$BRIDGE"
export var_net="$IPV4_CIDR"
export var_gateway="$GATEWAY"
export var_ipv6_method='none'
export var_ns="$NAMESERVER"
export var_timezone='Europe/Berlin'
export var_container_storage="$CONTAINER_STORAGE"
export var_template_storage="$TEMPLATE_STORAGE"
export var_protection='yes'
export var_ssh='no'
export var_tags='container;litecoin;wallet;ansible'
export var_post_install="$POST_INSTALL_HOOK"
log "creating CT ${CTID} with the pinned Community Scripts Debian helper"
bash "$helper_path"
pct config "$CTID" >/dev/null 2>&1 ||
die "helper returned without creating CT ${CTID}"
# Community Scripts does not currently expose an LXC swap variable.
pct set "$CTID" --swap 1024
config="$(pct config "$CTID")"
grep -qx 'cores: 2' <<<"$config" || die 'unexpected CPU allocation'
grep -qx 'memory: 4096' <<<"$config" || die 'unexpected memory allocation'
grep -qx 'swap: 1024' <<<"$config" || die 'unexpected swap allocation'
grep -qx 'hostname: ltc-node' <<<"$config" || die 'unexpected hostname'
grep -qx 'nameserver: 10.0.0.14' <<<"$config" || die 'unexpected nameserver'
grep -qx 'onboot: 1' <<<"$config" || die 'onboot is not enabled'
grep -qx 'protection: 1' <<<"$config" || die 'container protection is not enabled'
grep -qx 'unprivileged: 1' <<<"$config" || die 'container is not unprivileged'
grep -qx 'timezone: Europe/Berlin' <<<"$config" || die 'unexpected timezone'
grep -Eq '^rootfs: local-lvm:.*,size=150G(,|$)' <<<"$config" ||
die 'unexpected root filesystem allocation'
net0="$(grep '^net0: ' <<<"$config")"
for expected_net_field in \
'name=eth0' \
'bridge=vmbr0' \
'gw=10.0.0.1' \
'ip=10.0.0.61/24' \
'type=veth'; do
[[ "$net0" == *"$expected_net_field"* ]] ||
die "net0 is missing ${expected_net_field}"
done
[[ "$(pct status "$CTID")" == 'status: running' ]] || die "CT ${CTID} is not running"
hook_log="/var/log/community-scripts/post-install-${CTID}.log"
[[ -f "$hook_log" ]] || die "post-install hook log is missing: ${hook_log}"
grep -Fq "CT ${CTID} access bootstrap completed" "$hook_log" ||
die "post-install hook did not report successful completion; inspect ${hook_log}"
pct exec "$CTID" -- sh -eu -c '
test "$(hostname --short)" = ltc-node
test "$(. /etc/os-release; printf %s "$ID")" = debian
test "$(. /etc/os-release; printf %s "$VERSION_ID")" = 13
test "$(id -u ghost-agent)" = 1000
test "$(id -u ghost)" = 1001
test "$(id -u ansible-deploy)" = 1002
test "$(runuser -u ansible-deploy -- sudo -n id -u)" = 0
systemctl is-active --quiet ssh.service
'
log "CT ${CTID} provisioning and access bootstrap verified"
log "review ${hook_log}, record the SSH host-key fingerprint, then set the ghost password interactively"
log "command: pct exec ${CTID} -- passwd ghost"
+9
View File
@@ -38,6 +38,15 @@ Aktuell verwaltete Host-State:
`/root/.ssh/known_hosts` gepinnt. Log:
`/var/log/ghostnet-lxc-backup-sync.log`. Eingerichtet am 10.11.2026
(GNAI-000 Abschnitt 4 Punkt 4; erster Lauf und Restore-Test bestanden).
- **Tägliche Snapshots für CT 114 (Litecoin Wallet)**: Rolle
`pve_lxc_snapshot` — Skript
`/usr/local/sbin/ghostnet-lxc-snapshot-ct114.sh` plus Timer
`ghostnet-lxc-snapshot-ct114.timer` (täglich 04:00) erzeugen
`pct snapshot 114 ghostnet-daily-<timestamp>` und prunen auf die 7
neuesten Snapshots. CT 114 ist bewusst nicht Teil des vzdump-Backup-Jobs
(150 GiB Chain ist re-syncbar; `wallet.dat` wird clientseitig
verschlüsselt via restic aus dem CT heraus gesichert). Log:
`/var/log/ghostnet-lxc-snapshot-ct114.log` (GNAI-024 Abschnitt 9).
Die CT-Lebenszyklus-Skripte (`proxmox/lxc/<ct>/scripts/`: `pct create`,
Dist-Upgrade) bleiben Bootstrap-Skripte und laufen einmalig manuell als
@@ -9,3 +9,4 @@
- role: pve_media_cron
- role: pve_nfs_export
- role: pve_lxc_backup_sync
- role: pve_lxc_snapshot
@@ -0,0 +1,12 @@
# pve_lxc_snapshot
Daily snapshot of CT 114 (Litecoin wallet LXC) on the PVE host, GNAI-024
Abschnitt 9: `pct snapshot 114 ghostnet-daily-<timestamp>` every night at
04:00, retention of the newest 7 snapshots (`pct listsnapshot` /
`pct delsnapshot`), log at `/var/log/ghostnet-lxc-snapshot-ct114.log`.
CT 114 is deliberately not part of the vzdump backup job: the 150 GiB chain
is re-syncable on restore, and `wallet.dat` is covered by the client-side
encrypted restic backups from inside the CT plus these snapshots. The
snapshots require snapshot-capable storage (`local-lvm` / ZFS), which the
provisioning script preflights.
@@ -0,0 +1,11 @@
---
# Daily LXC snapshots for CT 114 (Litecoin wallet node, GNAI-024 Abschnitt 9).
# CT 114 is deliberately excluded from the vzdump backup job (150 GiB chain is
# re-syncable; wallet.dat is covered by encrypted restic backups and these
# snapshots), so local-lvm snapshots are its container-level recovery layer.
pve_lxc_snapshot_ctid: 114
pve_lxc_snapshot_name_prefix: ghostnet-daily
pve_lxc_snapshot_keep: 7
pve_lxc_snapshot_script: /usr/local/sbin/ghostnet-lxc-snapshot-ct114.sh
pve_lxc_snapshot_log: /var/log/ghostnet-lxc-snapshot-ct114.log
pve_lxc_snapshot_timer_oncalendar: '*-*-* 04:00:00'
@@ -0,0 +1,4 @@
---
- name: Reload systemd daemon
ansible.builtin.systemd_service:
daemon_reload: true
@@ -0,0 +1,44 @@
---
- name: Install the CT 114 snapshot script
ansible.builtin.template:
src: ghostnet-lxc-snapshot-ct114.sh.j2
dest: "{{ pve_lxc_snapshot_script }}"
owner: root
group: root
mode: "0750"
validate: /bin/bash -n %s
- name: Install the CT 114 snapshot systemd service
ansible.builtin.template:
src: ghostnet-lxc-snapshot-ct114.service.j2
dest: /etc/systemd/system/ghostnet-lxc-snapshot-ct114.service
owner: root
group: root
mode: "0644"
notify: Reload systemd daemon
- name: Install the CT 114 snapshot systemd timer
ansible.builtin.template:
src: ghostnet-lxc-snapshot-ct114.timer.j2
dest: /etc/systemd/system/ghostnet-lxc-snapshot-ct114.timer
owner: root
group: root
mode: "0644"
notify: Reload systemd daemon
- name: Create the snapshot log file
ansible.builtin.file:
path: "{{ pve_lxc_snapshot_log }}"
state: touch
owner: root
group: root
mode: "0640"
modification_time: preserve
access_time: preserve
- name: Enable and start the CT 114 snapshot timer
ansible.builtin.systemd_service:
name: ghostnet-lxc-snapshot-ct114.timer
enabled: true
state: started
daemon_reload: true
@@ -0,0 +1,7 @@
[Unit]
Description=Ghostnet daily snapshot of CT 114 (Litecoin wallet LXC)
[Service]
Type=oneshot
ExecStart={{ pve_lxc_snapshot_script }}
# Runs as root: pct snapshot requires host root.
@@ -0,0 +1,31 @@
#!/bin/bash
# {{ ansible_managed }}
# Daily snapshot of CT 114 with retention, installed by role pve_lxc_snapshot
# (GNAI-024 Abschnitt 9). Snapshots protect against container-level
# corruption; they do not replace the encrypted wallet backup.
set -euo pipefail
CTID="{{ pve_lxc_snapshot_ctid }}"
PREFIX="{{ pve_lxc_snapshot_name_prefix }}"
KEEP="{{ pve_lxc_snapshot_keep }}"
LOG="{{ pve_lxc_snapshot_log }}"
log() { echo "$(date -u +%FT%TZ) $*" >> "$LOG"; }
pct config "$CTID" >/dev/null 2>&1 || { log "FAIL CT $CTID does not exist"; exit 1; }
name="${PREFIX}-$(date +%Y%m%d-%H%M%S)"
pct snapshot "$CTID" "$name" --description "ghostnet daily snapshot (keep ${KEEP})" \
|| { log "FAIL pct snapshot $CTID $name"; exit 1; }
log "OK created snapshot $name for CT $CTID"
# Retention: keep the newest KEEP snapshots of this prefix, delete older ones.
pct listsnapshot "$CTID" \
| awk -v prefix="$PREFIX" '$1 == prefix || $1 ~ "^"prefix"-" { print $1 }' \
| sort -r \
| tail -n +"$((KEEP + 1))" \
| while read -r old; do
pct delsnapshot "$CTID" "$old" && log "OK pruned snapshot $old" || log "FAIL prune $old"
done
log "DONE CT $CTID snapshot run"
@@ -0,0 +1,9 @@
[Unit]
Description=Daily snapshot of CT 114 (Litecoin wallet LXC)
[Timer]
OnCalendar={{ pve_lxc_snapshot_timer_oncalendar }}
Persistent=true
[Install]
WantedBy=timers.target