I am using KDE on Arch Linux and I am trying to run gpg-agent in ssh-agent emulation mode as described here.

I created env file ~/.config/environment.d/80_gpg_agent.conf for systemd-environmentd-generator:


I do not set SSH_AGENT_PID because it is not accepted by mentioned generator but it shouldn't be set anyway (and it isn't).

If I start my system and login into TTY I am getting correct value for SSH_AUTH_SOCK (from systemctl --user show-environment):
Then, if I don't login into KDE session I have correct value for SSH_AUTH_SOCK:


After I log into KDE session (doesn't matter if it is Wayland or X11) I see that this value of overwritten by something:


This value looks like standard value usually set for ssh-agent but I don't have unit files for ssh-agent autostart.

So far I checked the following:

  • there is no code that sets SSH_AUTH_SOCK in .bashrc, .profile, /etc/bash.bashrc, /etc/profile or /etc/profile.d/*
  • there are no env variables in /etc/environment or ~/.config/environment.d/* besides one that I set for gpg-agent
  • I use keepassxc that has embedded ssh-agent but I didn't add it to autostart and its ssh-agent disabled

So, question is, where is it set and how do I stop this from overriding my env?

1 Answer 1


It seems like issue was due to use of (deprecated) ~/.pam_environment of pam_env module.

I found out that ~/.pam_environment has override for SSH_AUTH_SOCK=${XDG_RUNTIME_DIR}/ssh-agent.socket

Since it is marked as deprecated I didn't even thought it might be used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.