The answer to How to start and use ssh-agent as systemd service? gets us a running ssh-agent. How can you write another systemd service file so that its process runs under that ssh-agent? In particular I want to run an emacs service so that I can edit remote files using tramp.
This service file starts emacs but it's not running under ssh-agent.
[Unit]
Description=Emacs text editor
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
After=ssh-agent.service
[Service]
Type=simple
ExecStart=/usr/bin/emacs --fg-daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
Restart=on-failure
[Install]
WantedBy=default.target
Environment
setting, right? What should the%t
expand to ? – q.undertow Jan 27 '24 at 22:03ENVIRONMENT=SSH_AUTH_SOCK=%t/keyring/ssh
– q.undertow Jan 27 '24 at 22:23