AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 782459
Accepted
Ryan Lue
Ryan Lue
Asked: 2024-08-24 05:38:50 +0800 CST2024-08-24 05:38:50 +0800 CST 2024-08-24 05:38:50 +0800 CST

systemd 不断重新启动 gpg-agent,即使 gpg-agent.service 和 gpg-agent*.socket 被屏蔽

  • 772

目标:我正在尝试杀死 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._
              `"""
systemd
  • 1 1 个回答
  • 28 Views

1 个回答

  • Voted
  1. Best Answer
    Ryan Lue
    2024-08-27T02:38:57+08:002024-08-27T02:38:57+08:00

    我不完全明白发生了什么,但看起来@Stephen Kitt 是正确的,而且 systemd 毕竟没有受到指责:

    根据这里的建议,我补充道

    # ~/.gnupg/gpg.conf
    
    no-autostart
    

    问题就解决了。

    • 0

相关问题

  • journalctl 中的区分级别

  • 将默认编辑器更改为 vim for _ sudo systemctl edit [unit-file] _

  • systemd:如何在服务启动时运行脚本,而不编辑服务定义

  • 使用 systemd 看门狗支持重新启动应用程序

  • 使用键盘快捷键启动/停止 systemd 服务 [关闭]

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve