Unattended install using ssh key

I’m trying to specify the ssh key I’ve created for the restic user account, mentioned here: Examples — restic 0.11.0 documentation

The problem I think I’m running into is that I don’t know how to tell restic to use the restic user’s key when connecting. I’ve tried running as the user with this command and it fails

sudo -u restic /home/restic/bin/restic -r sftp -o "IdentityFile=/home/restic/.ssh/restic":restic@ --verbose --verbose backup --exclude-file=restic_exclusions --files-from=restic_inclusions

the -o flag is invalid in this case but I left it there to give better context. I am able to get this to work using my account, just not the restic account that I want to use for the unattended backups.

Can anyone tell me how to do this? Thank you.

The easiest way is to add a corresponding entry to your ~/.ssh/config file:

Host restic-backup-host
    User restic
    IdentityFile /home/restic/.ssh/restic

Then the command-line would be: sudo -u restic /home/restic/bin/restic -r sftp:restic-backup-host:/mnt/data/backup/repos/clowncar -v=2 backup --exclude-file=restic_exclusions --files-from=restic_inclusions

Hi, thank you for your reply. I’m just now getting back to this!
Do I need to somehow supply the password for the restic user account, or can I just add a bash script to cron?

nevermind, I found the page. Thanks again.