Ssh authentification in daemon mode

Hi,

What happened?

If I run emacs in daemon-mode (start emacs daemon and login with systemctl and open a emacsclient), magit is not able to communicate with remote server.

This post (emacs.stackexchange.com) is basically describing precisely my problem. From what I understand, emacs has (in daemon mode) some problem with loading ssh keys and that’s why magit fails.

In the post they also suggest a solution which I tried to adapt to doom emacs logic:

(package! exec-path-from-shell) ;; in packages.el

(use-package exec-path-from-shell
  :config
  (dolist (var '("PATH" "SSH_AUTH_SOCK" "SSH_AGENT_PID" "GPG_AGENT_INFO"
                 "LANG" "LC_CTYPE" "NIX_SSL_CERT_FILE" "NIX_PATH" "XAUTHORITY"))
    (add-to-list 'exec-path-from-shell-variables var))
  (exec-path-from-shell-initialize))

But afterwards, magit is still responding with the error:

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Do you have any hints for me how to fix this problem? Thanks for your time and help in advance!

Best regards Ludwig

Steps to reproduce

  1. Configure emacs to start at login systemctl --user enable emacs
  2. Reboot && Login
  3. Start emacs emacsclient -c
  4. Open a project with git and ssh authentification at origin
  5. Try magit to fetch updates

System information


Loading data dump...

I think I used to have the same issue. I fixed it with:

(after! doom-cli-env
  (add-to-list 'doom-env-allow "^SSH_"))

(that is with a Doom env file), which I took from there:

Hope it helps.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.