From 80fb782f3510da70f9e304c0a0f0f4e11bc409ae Mon Sep 17 00:00:00 2001 From: spektr Date: Fri, 27 Nov 2026 07:19:26 +0100 Subject: [PATCH] CT 114: restic sftp per dedizierter ssh_config (-F) statt langem sftp.command restic 0.18 zerlegt sftp.command unsauber; ssh_config mit absoluten Pfaden (IdentityFile/UserKnownHostsFile/BatchMode) ist robust, weil ssh ~ aus dem passwd-Eintrag liest. Rolle installiert /etc/litecoin-backup/ssh_config (0600). Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- .../ansible/roles/litecoin_backup/defaults/main.yml | 1 + .../ansible/roles/litecoin_backup/tasks/main.yml | 8 ++++++++ .../templates/litecoin-restic-check.service.j2 | 2 +- .../templates/litecoin-wallet-backup.sh.j2 | 4 ++-- .../roles/litecoin_backup/templates/ssh_config.j2 | 12 ++++++++++++ 5 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/ssh_config.j2 diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/defaults/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/defaults/main.yml index 00ba762..5d08eb0 100644 --- a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/defaults/main.yml +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/defaults/main.yml @@ -10,6 +10,7 @@ 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" +litecoin_backup_ssh_config: "{{ litecoin_backup_env_dir }}/ssh_config" # 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: >- diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/tasks/main.yml b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/tasks/main.yml index c373a69..f71ab52 100644 --- a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/tasks/main.yml +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/tasks/main.yml @@ -25,6 +25,14 @@ mode: "0600" create: true +- name: Install the dedicated ssh client config for the restic sftp backend + ansible.builtin.template: + src: ssh_config.j2 + dest: "{{ litecoin_backup_ssh_config }}" + owner: root + group: root + mode: "0600" + - name: Require the operator-provided restic SSH key ansible.builtin.stat: path: "{{ litecoin_backup_ssh_key }}" diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-restic-check.service.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-restic-check.service.j2 index 48b87b0..894ee3f 100644 --- a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-restic-check.service.j2 +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-restic-check.service.j2 @@ -6,5 +6,5 @@ Type=oneshot Environment=RESTIC_REPOSITORY={{ litecoin_backup_repository }} Environment=RESTIC_PASSWORD_FILE={{ litecoin_backup_password_file }} Environment=SSH_AUTH_SOCK= -ExecStart=/usr/bin/restic -o sftp.command="ssh -i {{ litecoin_backup_ssh_key }} -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile={{ litecoin_backup_known_hosts }}" check --read-data-subset=5% +ExecStart=/usr/bin/restic -o sftp.command="ssh -F {{ litecoin_backup_ssh_config }}" check --read-data-subset=5% Nice=10 diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-wallet-backup.sh.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-wallet-backup.sh.j2 index 86b37ee..6ae9991 100644 --- a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-wallet-backup.sh.j2 +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/litecoin-wallet-backup.sh.j2 @@ -11,8 +11,8 @@ export RESTIC_REPOSITORY="{{ litecoin_backup_repository }}" export RESTIC_PASSWORD_FILE="{{ litecoin_backup_password_file }}" # ssh resolves ~ from the passwd entry, not from $HOME, so the restic sftp -# backend gets the key and known_hosts explicitly via sftp.command. -SFTP_COMMAND="ssh -i {{ litecoin_backup_ssh_key }} -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile={{ litecoin_backup_known_hosts }}" +# backend gets a dedicated client config via sftp.command. +SFTP_COMMAND="ssh -F {{ litecoin_backup_ssh_config }}" backup_dir="{{ litecoin_backup_wallet_dir }}" today="$(date +%F)" diff --git a/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/ssh_config.j2 b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/ssh_config.j2 new file mode 100644 index 0000000..c185b50 --- /dev/null +++ b/proxmox/lxc/ct-114-litecoin-wallet/ansible/roles/litecoin_backup/templates/ssh_config.j2 @@ -0,0 +1,12 @@ +# Managed by Ansible role litecoin_backup. +# Dedicated ssh client config for the restic sftp backend (restic runs +# `ssh -F gn-backup@10.0.0.90 -s sftp`); ssh resolves ~ from +# the passwd entry, so all paths are absolute. +Host {{ litecoin_backup_target_host }} + HostName {{ litecoin_backup_target_host }} + User gn-backup + IdentityFile {{ litecoin_backup_ssh_key }} + IdentitiesOnly yes + BatchMode yes + StrictHostKeyChecking yes + UserKnownHostsFile {{ litecoin_backup_known_hosts }}