[arch-general] Env variable of user unit of ssh-agent not set
Hi, I followed 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. Thanks Rainer
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
Hi, you probably missed this part (quoted from your link):
Then export the environment variable SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket" in your login shell initialization file, such as ~/.bash_profile or ~/.zprofile.
Regards, Merlin -- Merlin Büge
Am Samstag, 22. Januar 2022, 07:26:01 CET schrieb Merlin Büge:
Hi,
you probably missed this part (quoted from your link):
Then export the environment variable SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket" in your login shell initialization file, such as ~/.bash_profile or ~/.zprofile.
Many thanks for the quick responses. Indeed that resolves the problem. I expected that Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket takes care for that. But it seems that this only applies to the process which is stated by the unit (?). Thanks Rainer.
participants (3)
-
eNV25
-
Merlin Büge
-
Rainer Dorsch