<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>运维安全 on MeerStory</title><link>https://linux.meerstory.com/zh/categories/%E8%BF%90%E7%BB%B4%E5%AE%89%E5%85%A8/</link><description>Recent content in 运维安全 on MeerStory</description><generator>Hugo</generator><language>zh-cn</language><lastBuildDate>Sun, 11 Oct 2026 01:27:18 +0900</lastBuildDate><atom:link href="https://linux.meerstory.com/zh/categories/%E8%BF%90%E7%BB%B4%E5%AE%89%E5%85%A8/index.xml" rel="self" type="application/rss+xml"/><item><title>Linux GPG 主目录平滑迁移实战：使用 addgnupghome 规范化密钥存储路径</title><link>https://linux.meerstory.com/zh/ubuntu/20261011_012642_32/</link><pubDate>Sun, 11 Oct 2026 01:27:18 +0900</pubDate><guid>https://linux.meerstory.com/zh/ubuntu/20261011_012642_32/</guid><description>&lt;h2 id="概述">概述&lt;/h2>
&lt;p>在维护 Linux 服务器与开发环境时，规范并重构敏感数据的存储路径是系统架构演进中的常见需求。当需要将 GPG 密钥环、信任数据库及配置文件整合或重组至新目录结构时，系统自带的 &lt;code>addgnupghome&lt;/code> 实用程序提供了一种标准化、低风险的迁移途径。本篇技术指南将系统解析 &lt;code>addgnupghome&lt;/code> 的工作机制，并通过端到端的操作演练，详细展示从遗留密钥构建、跨目录数据迁移到权限严苛加固的全套工程实践。&lt;/p>
&lt;h2 id="1-部署-gnupg-组件并探查-addgnupghome-命令行工具">1. 部署 GnuPG 组件并探查 addgnupghome 命令行工具&lt;/h2>
&lt;p>执行密钥迁移与系统集成的前提是确保本地拥有完整的 GnuPG 运行时环境，首先同步软件源并安装 &lt;code>gnupg&lt;/code> 与签名校验工具 &lt;code>gpgv&lt;/code>。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261011_012642_32/captures/s01_c01_sudo_apt-get_update_-qq____sudo_apt-get_install_-y.png"
 alt="执行软件包更新并安装 gnupg 套件"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;p>接着调用 &lt;code>which&lt;/code> 定位可执行文件，确认底层维护脚本 &lt;code>addgnupghome&lt;/code> 是否已就绪并存在于管理员路径 &lt;code>/usr/sbin/addgnupghome&lt;/code> 下。&lt;br>
从架构设计来看，&lt;code>addgnupghome&lt;/code> 主要用于为指定系统账户或特定目录生成标准化的 GnuPG 主目录（&lt;code>~/.gnupg&lt;/code>）架构，同时兼顾旧版本数据结构的过渡与重组。&lt;br>
⚙️ [核心参数说明]&lt;/p>
&lt;p>&lt;code>account&lt;/code> : 指定待初始化或接受迁移操作的目标系统用户名或对应环境标识。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261011_012642_32/captures/s01_c02_which_addgnupghome.png"
 alt="验证 addgnupghome 二进制文件路径"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;p>通过传参或查询联机帮助来查看命令使用手册。&lt;br>
需注意，在某些经过精简裁剪（Minimized）的 Ubuntu 云镜像或容器实例中，man 文档可能已被剥离，控制台会输出相应的提示指引。&lt;/p>
&lt;p>&lt;img src="captures/s03_c01_addgnupghome_--help____man_addgnupghome___head_-n.png"
 alt="查看命令帮助信息与手册状态"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p>
&lt;h2 id="2-模拟真实环境搭建测试用旧版-gpg-目录与密钥资产">2. 模拟真实环境：搭建测试用旧版 GPG 目录与密钥资产&lt;/h2>
&lt;p>为了在受控环境下模拟生产迁移，先在临时目录划定一块旧版数据存放区，并严格限定其访问权限为 &lt;code>700&lt;/code> 以符合安全基线。&lt;/p>
&lt;p>&lt;img src="https://linux.meerstory.com/ubuntu/20261011_012642_32/captures/s02_c01_mkdir_-p__tmp_legacy-gnupg____chmod_700__tmp_legac.png"
 alt="初始化遗留数据目录并收紧访问权限"
 
 loading="lazy"
 decoding="async"
 style="max-width: 100%; height: auto;">


&lt;/p></description></item></channel></rss>