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 <vibe@mistral.ai>
This commit is contained in:
@@ -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.
|
# 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_ssh_key: "{{ litecoin_backup_env_dir }}/.ssh/id_ed25519"
|
||||||
litecoin_backup_known_hosts: "{{ litecoin_backup_env_dir }}/.ssh/known_hosts"
|
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.
|
# ghostnet-ki host key (ed25519), same pin as pve_lxc_backup_sync.
|
||||||
litecoin_backup_target_host: 10.0.0.90
|
litecoin_backup_target_host: 10.0.0.90
|
||||||
litecoin_backup_target_host_key_ed25519: >-
|
litecoin_backup_target_host_key_ed25519: >-
|
||||||
|
|||||||
@@ -25,6 +25,14 @@
|
|||||||
mode: "0600"
|
mode: "0600"
|
||||||
create: true
|
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
|
- name: Require the operator-provided restic SSH key
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ litecoin_backup_ssh_key }}"
|
path: "{{ litecoin_backup_ssh_key }}"
|
||||||
|
|||||||
+1
-1
@@ -6,5 +6,5 @@ Type=oneshot
|
|||||||
Environment=RESTIC_REPOSITORY={{ litecoin_backup_repository }}
|
Environment=RESTIC_REPOSITORY={{ litecoin_backup_repository }}
|
||||||
Environment=RESTIC_PASSWORD_FILE={{ litecoin_backup_password_file }}
|
Environment=RESTIC_PASSWORD_FILE={{ litecoin_backup_password_file }}
|
||||||
Environment=SSH_AUTH_SOCK=
|
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
|
Nice=10
|
||||||
|
|||||||
+2
-2
@@ -11,8 +11,8 @@ export RESTIC_REPOSITORY="{{ litecoin_backup_repository }}"
|
|||||||
export RESTIC_PASSWORD_FILE="{{ litecoin_backup_password_file }}"
|
export RESTIC_PASSWORD_FILE="{{ litecoin_backup_password_file }}"
|
||||||
|
|
||||||
# ssh resolves ~ from the passwd entry, not from $HOME, so the restic sftp
|
# ssh resolves ~ from the passwd entry, not from $HOME, so the restic sftp
|
||||||
# backend gets the key and known_hosts explicitly via sftp.command.
|
# backend gets a dedicated client config 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 }}"
|
SFTP_COMMAND="ssh -F {{ litecoin_backup_ssh_config }}"
|
||||||
|
|
||||||
backup_dir="{{ litecoin_backup_wallet_dir }}"
|
backup_dir="{{ litecoin_backup_wallet_dir }}"
|
||||||
today="$(date +%F)"
|
today="$(date +%F)"
|
||||||
|
|||||||
+12
@@ -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 }}
|
||||||
Reference in New Issue
Block a user