目标:我正在尝试杀死 gpg-agent(在 Debian 12 上,如果这很重要的话)并让它永远消失。
旁白:为什么?
因为我刚刚设置好 GPG 代理转发到我的 SSH 服务器。尝试了一些指南都没有成功,直到我找到了这个,它建议:
$ gpg-connect-agent KILLAGENT /bye
在远程主机上。这样,GPG 代理转发终于可以正常工作了……
...但是如果我从另一个客户端(不将其 gpg-agent 套接字转发到远程主机的客户端)登录,则systemd 将重新启动 gpg-agent:
# Killing gpg-agent ---------------------------------------------
$ ssh <host>
$ gpg-connect-agent KILLAGENT /bye
OK closing connection
$ exit
logout
Connection to <host> closed
# Logging in with GPG socket forwarding: gpg-agent stays dead ---
$ ssh <host>
$ pgrep gpg-agent
# 👌 no output
$ gpg --list-secret-keys
/home/rlue/.config/gnupg/pubring.kbx
------------------------------------
sec rsa3072/... # 🎉 it works!
$ exit
logout
Connection to <host> closed
# Logging in from another client: gpg-agent is back -------------
$ ssh <host>
$ pgrep gpg-agent
17077 # 🤬 bad systemd!
您怎么知道它是 systemd?
$ pstree --show-parents --show-pids $(pidof gpg-agent)
systemd(1)---systemd(663)---gpg-agent(17077)
这很令人费解,因为......
这一切都是在运行后发生的:
$ systemctl --user mask --now gpg-agent.service gpg-agent.socket gpg-agent-ssh
.socket gpg-agent-extra.socket gpg-agent-browser.socket
$ systemctl --user daemon-reload
我甚至重新启动了(参见Uptime
最后一部分)。作为参考,以下是所有用户 systemd 单元的状态:
$ systemctl --user list-unit-files
UNIT FILE STATE PRESET
app-print\[email protected] generated -
at-spi-dbus-bus.service static -
dbus.service static -
dcim-transfer.photein.service disabled enabled
dcim-transfer.xferase.service disabled enabled
dconf.service static -
dirmngr.service static -
glib-pacrunner.service static -
gnubiff.service enabled enabled
gpg-agent.service masked enabled
pipewire-pulse.service enabled enabled
pipewire.service enabled enabled
pk-debconf-helper.service static -
shpool.service enabled enabled
ssh-agent.service static -
systemd-exit.service static -
systemd-tmpfiles-clean.service static -
systemd-tmpfiles-setup.service disabled enabled
wireplumber.service enabled enabled
[email protected] disabled enabled
xdg-desktop-portal-gtk.service static -
xdg-desktop-portal-rewrite-launchers.service enabled enabled
xdg-desktop-portal.service static -
xdg-document-portal.service static -
xdg-permission-store.service static -
xferase.service disabled enabled
app.slice static -
background.slice static -
session.slice static -
dbus.socket static -
dirmngr.socket enabled enabled
gpg-agent-browser.socket masked enabled
gpg-agent-extra.socket masked enabled
gpg-agent-ssh.socket masked enabled
gpg-agent.socket masked enabled
pipewire-pulse.socket enabled enabled
pipewire.socket enabled enabled
pk-debconf-helper.socket enabled enabled
shpool.socket enabled enabled
basic.target static -
bluetooth.target static -
default.target static -
exit.target static -
graphical-session-pre.target static -
graphical-session.target static -
paths.target static -
printer.target static -
shutdown.target static -
smartcard.target static -
sockets.target static -
sound.target static -
timers.target static -
xdg-desktop-autostart.target static -
systemd-tmpfiles-clean.timer disabled enabled
54 unit files listed.
发生了什么事?任何指示都将不胜感激。
操作系统和其他详细信息
$ neofetch
_,met$$$$$gg. rlue@<host>
,g$$$$$$$$$$$$$$$P. -------------
,g$$P" """Y$$.". OS: Debian GNU/Linux 12 (bookworm) x86_64
,$$P' `$$$. Host: KVM/QEMU (Standard PC (i440FX + PIIX, 1996) pc-i440fx-5.2)
',$$P ,ggs. `$$b: Kernel: 6.1.0-23-amd64
`d$$' ,$P"' . $$$ Uptime: 38 mins
$$P d$' , $$P Packages: 1549 (dpkg)
$$: $$. - ,d$$' Shell: bash 5.2.15
$$; Y$b._ _,d$P' Resolution: 1024x768
Y$$. `.`"Y$$$$P"' Terminal: /dev/pts/0
`$$b "-.__ CPU: Intel Xeon E5-2690 v2 (4) @ 2.999GHz
`Y$$ GPU: 00:02.0 Vendor 1234 Device 1111
`Y$$. Memory: 3024MiB / 7940MiB
`$$b.
`Y$$b.
`"Y$b._
`"""