CT 114: restic sftp per dedizierter ssh_config (-F) statt langem sftp.command
ci-static / secret-scan (push) Successful in 22s
ci-static / yamllint (push) Successful in 31s
ci-static / ansible-syntax (push) Successful in 30s
ci-static / markdown-links (push) Successful in 21s

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 <vibe@mistral.ai>
This commit is contained in:
2026-11-27 07:19:26 +01:00
parent 21e410e8cd
commit 80fb782f35
5 changed files with 24 additions and 3 deletions
@@ -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: >-
@@ -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 }}"
@@ -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
@@ -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)"
@@ -0,0 +1,12 @@
# Managed by Ansible role litecoin_backup.
# Dedicated ssh client config for the restic sftp backend (restic runs
# `ssh -F <this file> 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 }}