You are not logged in.

#1 2022-11-16 08:51:22

lv426
Member
Registered: 2022-11-11
Posts: 19

[SOLVED] ssh-agent is not started with systemd user

Did a lot of Googling and searching on this forum, but I am struggling to solve this after a few hours. If I run `ssh-add -l` it says: Could not open a connection to your authentication agent.

- I copy and pasted the exact code from the wiki, so there are no spelling or formatting errors.
- Typing `systemctl --user status ssh.agent.service` shows it active and running with no errors.
- In my ~/.zprofile I have `export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"`
- I have tried reloading/restarting the service, rebooting, and sourcing my .zprofile.
- I am running i3wm, LightDM display manager, and ZSH shell.

Last edited by lv426 (2022-11-25 18:57:07)

Offline

#2 2022-11-16 18:09:48

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,178

Re: [SOLVED] ssh-agent is not started with systemd user

Which code did you copy-paste from the wiki and where did you paste it exactly?

What is the actual output of systemctl --user status ssh-agent.service? (Note the hyphen rather than the dot - according to the wiki.)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#3 2022-11-16 20:15:28

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,427

Re: [SOLVED] ssh-agent is not started with systemd user

In my ~/.zprofile

I am running … LightDM display manager, …

https://man.archlinux.org/man/extra/zsh … DOWN_FILES
Your zprofile is irrelevant in this context, zsh isn't your login shell, https://wiki.archlinux.org/title/Enviro … nvironment
Try ~/.xprofile (but idk. whether lightdm executes that)

Other than that, please of course also answer cfr's questions

Offline

#4 2022-11-16 21:24:20

lv426
Member
Registered: 2022-11-11
Posts: 19

Re: [SOLVED] ssh-agent is not started with systemd user

cfr wrote:

Which code did you copy-paste from the wiki and where did you paste it exactly?

What is the actual output of systemctl --user status ssh-agent.service? (Note the hyphen rather than the dot - according to the wiki.)

Sorry about that. Section 4.1.1: Start ssh-agent with systemd user

It is possible to use the systemd/User facilities to start the agent. Use this if you would like your ssh agent to run when you are logged in, regardless of whether x is running.

~/.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
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.

Finally, enable or start the service with the --user flag.

Here is the code you asked for. I didn't mean to put a period in my original post.

● ssh-agent.service - SSH key agent
     Loaded: loaded (/home/lv426/.config/systemd/user/ssh-agent.service; enabled; preset: enabled)
     Active: active (running) since Wed 2022-11-16 13:04:36 PST; 12min ago
   Main PID: 416 (ssh-agent)
      Tasks: 1 (limit: 4659)
     Memory: 1.4M
        CPU: 6ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/ssh-agent.service
             └─416 /usr/bin/ssh-agent -D -a /run/user/1000/ssh-agent.socket

Nov 16 13:04:36 arch ssh-agent[416]: SSH_AUTH_SOCK=/run/user/1000/ssh-agent.socket; export SSH_AUTH_SOCK;
Nov 16 13:04:36 arch ssh-agent[416]: echo Agent pid 416;
Nov 16 13:04:36 arch systemd[407]: Started SSH key agent.

Offline

#5 2022-11-16 23:44:13

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,178

Re: [SOLVED] ssh-agent is not started with systemd user

printenv | grep SSH_AUTH_SOCK

CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#6 2022-11-17 01:53:00

lv426
Member
Registered: 2022-11-11
Posts: 19

Re: [SOLVED] ssh-agent is not started with systemd user

cfr wrote:
printenv | grep SSH_AUTH_SOCK

No results are returned.

Offline

#7 2022-11-17 08:19:08

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,427

Re: [SOLVED] ssh-agent is not started with systemd user

Quelle surprise.

seth wrote:

Your zprofile is irrelevant … Try ~/.xprofile

Offline

#8 2022-11-17 17:41:13

lv426
Member
Registered: 2022-11-11
Posts: 19

Re: [SOLVED] ssh-agent is not started with systemd user

seth wrote:

Quelle surprise.

seth wrote:

Your zprofile is irrelevant … Try ~/.xprofile

You say it's irrelevant but why is it listed on the wiki? Is the article out of date?

I don't have an ~/.xprofile, just ~/xinitrc, though of course I could make it.

Offline

#9 2022-11-17 17:49:46

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,261

Re: [SOLVED] ssh-agent is not started with systemd user

It's in the wiki because it would work if you used zsh as your login shell, but you don't you start a DM which doesn't use a login shell for login you in. .xprofile is what should/will be parsed by most display managers, assuming it exists, so yes, create that.

Offline

#10 2022-11-17 17:50:31

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,427

Re: [SOLVED] ssh-agent is not started with systemd user

Is the article out of date?

No.

seth wrote:

zsh isn't your login shell

I don't have an ~/.xprofile, … though of course I could make it.

Yes. Of course.

just ~/xinitrc,

If you're using lightdm, that's likewise irrelevant.

Offline

#11 2022-11-17 19:34:09

lv426
Member
Registered: 2022-11-11
Posts: 19

Re: [SOLVED] ssh-agent is not started with systemd user

I created .xprofile and added the necessary line, but it still cannot open a connection to the authentication agent.

I reloaded the service, as well as rebooted.

printenv | grep SSH_AUTH_SOCK still shows nothing

Offline

#12 2022-11-17 19:43:35

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,261

Re: [SOLVED] ssh-agent is not started with systemd user

You added what line? Post it. It should be

export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"

and yo

Offline

Board footer

Powered by FluxBB