2

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
2
  • I am stuck on this too :-( The problem is the Environment setting, right? What should the %t expand to ? Commented Jan 27, 2024 at 22:03
  • Here's what worked for me: ENVIRONMENT=SSH_AUTH_SOCK=%t/keyring/ssh Commented Jan 27, 2024 at 22:23

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.