How to let systemd user unit see keys in SSH agent?
I have a script that does
git fetch for a repository. When I run this in my shell it works fine.
I want to run it in a systemd user unit. However, I am using an SSH url, and the systemd unit fails with
fatal: Could not read from remote repository.' (Git exit code 128).
This is probably because systemd doesn't have access to my SSH key and/or cannot handle the interactive passphrase prompt.
I've seen solutions like creating a passwordless SSH key, but I don't want to do that. I also don't want to explicitly point it to the key, because this will be on several machines that have differently named keys. I'd rather make the systemd unit get the SSH key the same way
git fetch does for me: From the SSH agent. How can I do that?