https://wiki.archlinux.org/title/SSH_keys#Start_ssh-agent_with_systemd_user
It seems that SSH_AUTH_SOCK does not get set although it is in the user unit file.
$ systemctl --user status ssh-agent.service ● ssh-agent.service - SSH key agent Loaded: loaded (/home/rd/.config/systemd/user/ssh-agent.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2022-01-21 21:14:16 CET; 7min ago Main PID: 574 (ssh-agent) Tasks: 1 (limit: 9331) Memory: 920.0K CPU: 9ms CGroup: /user.slice/user-2809.slice/user@2809.service/app.slice/ssh- agent.service └─574 /usr/bin/ssh-agent -D -a /run/user/2809/ssh-agent.socket
Jan 21 21:14:16 n3150 ssh-agent[574]: SSH_AUTH_SOCK=/run/user/2809/ssh- agent.socket; export SSH_AUTH_SOCK; Jan 21 21:14:16 n3150 ssh-agent[574]: echo Agent pid 574; Jan 21 21:14:16 n3150 systemd[564]: Started SSH key agent. $ cat .config/systemd/user/ssh-agent.service [Unit] Description=SSH key agent
[Service] Type=simple Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket # DISPLAY required for ssh-askpass to work Environment=DISPLAY=:0 ExecStart=/usr/bin/ssh-agent -D -a $SSH_AUTH_SOCK
[Install] WantedBy=default.target $ ssh-add Could not open a connection to your authentication agent. $ echo $SSH_AUTH_SOCK
$
Can anybody tell what I am missing?
Any hint or advice is welcome.
I think you need to add the variable in your shell's rc and make it match the one in the service. I have `export SSH_AUTH_SOCK="${XDG_RUNTIME_DIR:-/run/user/$UID}/ssh-agent.socket"` in my ~/.zshrc