OK, the problem I had with this thread is that this is a very different setup than what I have here on jammy-based Neon. I have gnome-keyring 40 installed and that provides the ssh-agent functionality through the static user service gnome-keyring-ssh.service
.
On Debian 12, they use gnome-keyring 42, where - as far as I understand - the SSH agent functionality has been moved to gcr-ssh-agent
that is implemented as a systemd socket that runs the gcr-ssh-agent.service
(if you do systemctl --user cat gcr-ssh-agent.socket
you don’t see Service=
option, which means that when a client connects to the socket it launches a service unit with the same base name).
We can see gcr-ssh-agent.service
launched by the socket at 03:02:58
in your log (I’m assuming this is part of the session start process where you are running something that connects to the SSH agent). As far as I can tell - this service does not run the OpenSSH client’s ssh-agent.service
or runs the OpenSSH agent in any other manner - it implements its own SSH agent API on top of the GNOME keyring service.
Debian 12 also has a socket unit gpg-agent-ssh.socket
that is part of the gpg-agent
package that starts the gpg-agent.service
(use systemctl --user cat
and you can see it is listed explicitly) that apparently uses gpg-agent
to also implement the SSH agent protocol (though I think it is missing a require option to enable that, so I’m not sure it actually works. I haven’t tested it). Again this does not actually start the OpenSSH agent using the ssh-agent.service
systemd unit or otherwise - gpg-agent
also has a complete internal SSH agent implementation. We can see its socket starts at 03:02:57
in your log but no one connects to it so the service does not start.
So none of these immediate suspects are implicated in starting ssh-agent.service
so the question - what is starting it? The answer is that I believe I was hasty in declaring the systemctl disable
is the answer and systemctl mask
is never a good idea, and that may not be true:
The OpenSSH client installs its ssh-agent into as a required service in the graphical session, as can be seen by listing its package content:
$ dpkg -L openssh-client | grep systemd
/usr/lib/systemd
/usr/lib/systemd/user
/usr/lib/systemd/user/graphical-session-pre.target.wants
/usr/lib/systemd/user/ssh-agent.service
/usr/lib/systemd/user/graphical-session-pre.target.wants/ssh-agent.service
Because the dependency is written into the system, you can’t modify it with user tools (such as systemctl --user
) - I’m not sure why list-dependencies
doesn’t list it, I may misunderstood what its supposed to do. You can see the fact that ssh-agent.service
is hard-coded into the session if you run:
$ systemctl --user status ssh-agent.service
ssh-agent.service - OpenSSH Agent
Loaded: loaded (/usr/lib/systemd/user/ssh-agent.service, static)
Active: inactive (dead)
The static
part in the Loaded
property means exactly that - it is static in the system and you cannot disable or enable it with your user tools. If you try systemctl --user disable ssh-agent.service
, the tool won’t say anything, but it will not actually disable the service and will return an exit code of 1 (meaning “error”) and running systemctl --user is-enabled ssh-agent.service
will still say “static
”.
So yes - the only solution for preventing a static unit from starting is to mask it.
I should have tested this more - on my system ssh-agent.service
also exists and is “static”, but it isn’t actually running - I’m not sure why - it starts and then stops with no logs, probably there’s already an SSH agent implementation by the GNOME Keyring running - but I don’t understand the mechanism yet.