garlic的技术折腾记录

这里主要记录 Nginx / Linux / 网络 / Web3 / 节点运维等折腾过程,也偶尔写点生活随笔。

地牛:听见黄土下的回响

一、 传说 姥姥曾跟我讲过一个姥爷老家的传说。 在陕西长武的黄土塬底下,活着一种神物,叫“地牛”。 姥姥说:“那东西,你能听见它的声音,哞哞地叫,但你永远看不到它的影子。它就在土里走,在土里活。” 那时我不懂,直到二十多年后,拼凑出姥爷的一生,我才明白: 我的姥爷谢自熬,正如那头地牛,深埋在黄土中,默默无闻,却用自己的方式在大地上行走、活着。 二、 入伍 姥爷属狗,1922年生。 在《长武县志》的第743页,我找到了他人生的起点。民国三十三年(1944年)11月,响应“一寸河山一寸血,十万青年十万军”的号召,长武县征集了 92名 知识青年。姥爷读过两年私塾,他是这92个名字中的一个。 那一年他22岁,从黄土高坡出发,一路向南。 我在美军官方战史《二战中的美国陆军航空队》(Army Air Forces in World War II)第七卷里,查到了这段历史的记录:“Reverse Hump Tonnage”——运输机把汽油等物资运进昆明后,回程本该空舱。史迪威认为,空舱返航意味着浪费,于是把这些回程飞机变成运兵的通道:一批批中国的年轻士兵,被像“货物”一样装上舱门,飞向印度,去接受训练与命运的重写。(ibiblio.org) 战史也提到当时常用的 C-46 运输机:载重很大,但事故率高。飞机需要爬升到 15,000 英尺(约4500米)甚至更高才能翻越山脉;机舱里缺氧、严寒,而且没有加压舱。 姥爷当年的飞机,很可能就降落在那个叫“苏克雷廷”(Sookerating)的陌生机场。 在那份宏大的历史数据流里,姥爷谢自熬,就是那个具体的、鲜活的“1”。 三、 兄弟 最荒诞也最真实的剧本:哥哥(姥爷)进了国军,弟弟成了八路军。 同一个娘胎里出来的两兄弟,一个向南飞,一个向北走。 后来的几十年里,特别是文革那段特殊时期,兄弟俩几乎断了联系。姥爷从不提他有个八路军弟弟,弟弟也从不提有个当过“国军”的哥哥。 小时候我不懂,以为是感情淡了。现在才懂,那是无声的默契——在那个动荡的年代,互不打扰,就是对彼此最大的保护。 直到晚年,弟弟的两个孙子来看姥爷,还带了家乡的枣。只是他们说,河道变了,好多枣树都没了。 那个平日里沉默寡言的姥爷,那些天却格外高兴,拿出了家里最好的东西热情款待。 我想,看着那两个年轻人的脸,他看到的应该是几十年前,还在长武老家一起光屁股长大的兄弟俩吧。 姥姥说过,姥爷是老七,他还有个二哥当年也死在战场上。那个年月,对他们来说,参军也许就是最现实的一条活路。 四、 丢失的纸 抗战胜利后,命运跟他开了一个巨大的玩笑。 他随部队回国,驻守张家口,归傅作义指挥。1949年北平和平解放,他成了“起义人员”,拿到了一张足以改变命运的纸——《解放军复员证明书》(解放证)。 但在回陕西老家的路上,遭遇国民党残部,这张保命的证件被抢走了。 那一刻,他的人生被硬生生折断了。 没有了证明,他回不去部队,也回不去荣耀。为了活着,他只能折返,回到了张家口桥西的**“瓦盆窑”**。 从远征军的精锐到窑厂的苦力,曾经握枪的手拿起了铲子。他把所有的委屈咽进肚子里,把他所有的经历,都一起扔进了窑炉,烧成了那个年代最廉价的煤灰。 五、 缘分 姥姥脾气暴躁,我从小在骂声里长大。她骂得最多的就是我姥爷,“老兔子”这三个字,我听了许多年。于是后来我开会,听见甲方领导拍桌子呵斥,反倒不太怕了。可姥爷总替她解释:她只是嘴硬,心不坏。 姥爷不太会做家务。他洗碗的“收尾”方式很特别:碗里剩一点水,就随手倒在床上——那时候床上铺着厚塑料布,摆着小方桌,我们就在那儿吃饭。 姥姥的身世也苦。她说父亲吸大烟,小时候把她挂着牌子放到街上“卖”,却没人要。她靠捡煤渣、靠施粥活下来。后来日本人来了,她去给日本人当保姆,做饭,看孩子。 也许正是那个动荡年代里,这两个人带着各自的伤痕走到了一起,这就叫缘分。 六、 十年 回到张家口,他和姥姥有了两个孩子,一个男孩一个女孩。女孩就是我的母亲,男孩下乡后留在当地。 我印象最深的是妈妈说,那个年代学生上街游行,需要每个人扛一个红缨枪。别人家都拿着木头杆子的,姥爷不会弄,直接给她拿了根铁杆子的。一圈游行下来,可把她累得够呛,她说起来又气又好笑。 抗美援朝时,当时还征兵,但是姥姥这次说什么也没让姥爷去。 七、 回忆 记忆中,总有一个胖墩墩的老头,手里提着一个黑色皮包,缓慢地走到我们街道尽头,向左一拐,消失在我的视野里。 前两天我到附近的小店买东西的时候,发现了小时候经常吃的“栗子羹”,一下子就想起了我的姥爷。 **2000年姥爷去世。**他是个沉默的人,但是对人总是笑嘻嘻的,包括被姥姥骂,也是笑一笑就走开了。小时候有要家长默写汉字的作业,我就喜欢找他。因为他上私塾学的是繁体字,有时候看简体字会念错,我就能借机会看一下我不会写的字,哈哈。默写完还得让他帮我签一个字。 姥爷原来在窑厂上班,退休后在街道办事处门房看大门。周末他上白班的时候我就去找他。那时候办事处还有一个大院子,姥爷浇花的时候还捉住过一只小黄鸟,不过后来我打开笼子想看它时,它一下就飞走了。 还有一年,我们那边来了一个南疆过来的征兵干部,说是姥爷的老乡。姥爷听说后,二话没说,把家里的一床被子打包好送了过去。他说老乡被子薄,怕娃娃冻着。 那时家里并不富裕,但他就是这样,对自己抠搜,但见不得当兵的老乡受苦。或许在他心里,那个年轻的后生,就是当年那个只穿着单衣、在寒风中飞越驼峰的自己。 他睡觉打呼噜特别大声。夏天姥爷会一个人到南房睡觉,那边凉快。冬天的时候我在姥姥姥爷中间睡觉,他打呼噜震天响,我半夜醒来睡不着,经常把他推醒,然后自己赶紧睡觉。 还有一次我悄悄进屋大声一喊,把姥姥姥爷吓了一大跳,现在还能模糊记得那个场景,后来被我妈说了一顿。 这是我的姥爷 ...

2026-02-01 · 1 min · 142 words · Garlic Space

升级openssh

centos7 升级openssh 由于官方不再不支持选择源码编译方式 官方网站下载 https://zlib.net/ https://openssl-library.org/source/ https://www.openssh.com/portable.html zlib wget https://zlib.net/zlib-1.3.1.tar.gz tar xf zlib-1.3.1.tar.gz cd zlib-1.3.1 ./configure --prefix=/usr/local/zlib-1.3.1 sudo make sudo make install openssl wget https://github.com/openssl/openssl/releases/download/openssl-3.5.2/openssl-3.5.2.tar.gz tar xf openssl-3.5.2.tar.gz cd openssl-3.5.2 ./Configure \ --prefix=/usr/local/openssl-3.5.2 \ --openssldir=/usr/local/openssl-3.5.2/ssl \ enable-fips \ shared sudo make sudo make install openssh wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-10.0p2.tar.gz wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-10.0p2.tar.gz.asc wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/RELEASE_KEY.asc gpg --import RELEASE_KEY.asc gpg --verify openssh-10.0p2.tar.gz.asc gpg --edit-key 736060BA gpg> trust #然后选择 5 = I trust ultimately gpg> quit tar zxf openssh-10.0p2.tar.gz openssh-10.0p1 export PATH="/usr/local/openssl-3.5.2/bin:$PATH" export LD_LIBRARY_PATH="/usr/local/openssl-3.5.2/lib64:$LD_LIBRARY_PATH" ./configure \ --prefix=/usr/local/ssh \ --sysconfdir=/usr/local/ssh/etc \ --with-privsep-path=/usr/local/ssh/var/empty \ --with-zlib=/usr/local/zlib-1.3.1 \ --with-ssl-dir=/usr/local/openssl-3.5.2 \ --without-openssl-header-check sudo make sudo LD_LIBRARY_PATH="/usr/local/openssl-3.5.2/lib64:$LD_LIBRARY_PATH" make install 调整配置 ...

2025-08-24 · 1 min · 161 words

centos7 yum 源失效

centos7 yum 源已经失效, 可以通过下面指令更换默认配置, baseurl中 mirror.* 替换为 vault* sed -i -e '/^mirrorlist/d;/^#baseurl=/{s,^#,,;s,/mirror,/vault,;}' /etc/yum.repos.d/CentOS*.repo yum update -y https://jms1.info/linux/centos7-vault.html

2025-01-22 · 1 min · 17 words

NGINX Configuration for Multiple Certificates

NGINX typically supports two scenarios for configuring multiple certificates: Providing multiple certificate types (e.g., RSA and ECC) for the same domain. Hosting multiple domains on the same IP address, using different certificates selected based on the client-provided SNI. Generating Certificates Use the ssl_cert_chain_tool.sh script to generate a set of valid certificates: # RSA Certificates ssl_cert_chain_tool.sh -a RSA -o a_cert -n a.example.com -u ssl_cert_chain_tool.sh -a RSA -o b_cert -n b.example.com -u ssl_cert_chain_tool.sh -a RSA -o c_cert -n c.example.com -u # ECC Certificates ssl_cert_chain_tool.sh -a ECC -o d_cert -n d.example.com -u ssl_cert_chain_tool.sh -a ECC -o e_cert -n e.example.com -u Support for Multiple Certificate Types http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 0.0.0.0:443 ssl; ssl_protocols TLSv1.3 TLSv1.2; server_name a.example.com b.example.com c.example.com d.example.com e.example.com; ssl_prefer_server_ciphers on; # RSA and ECC Certificates ssl_certificate a_cert/server.cert.pem; ssl_certificate_key a_cert/server.key.pem; ssl_certificate e_cert/server.cert.pem; ssl_certificate_key e_cert/server.key.pem; ssl_certificate d_cert/server.cert.pem; ssl_certificate_key d_cert/server.key.pem; ssl_certificate c_cert/server.cert.pem; ssl_certificate_key c_cert/server.key.pem; ssl_certificate b_cert/server.cert.pem; ssl_certificate_key b_cert/server.key.pem; location / { return 200 'Multi-certificates test\n'; } } } During the handshake process, the server selects the appropriate certificate based on the signature algorithm. OpenSSL handles this in the tls_post_process_client_hello->tls_choose_sigalg function, which processes the client hello message and selects the most suitable certificate based on the signature algorithms and the server’s configuration. ...

2025-01-06 · 3 min · 501 words

nginx Multi-Certificates

NGINX 配置多个证书一般有两种场景: 同一个域名下提供多种类型证书,如RSA,ECC证书 多个域名部署在同一个IP,使用多个不同证书, 根据客户端上送SNI选择证书 生成证书 使用 ssl_cert_chain_tool.sh 生成一组正式证书 RSA 类型证书 ssl_cert_chain_tool.sh -a RSA -o a_cert -n a.example.com -u ssl_cert_chain_tool.sh -a RSA -o b_cert -n b.example.com -u ssl_cert_chain_tool.sh -a RSA -o c_cert -n c.example.com -u ECC 类型证书 ssl_cert_chain_tool.sh -a ECC -o d_cert -n d.example.com -u ssl_cert_chain_tool.sh -a ECC -o e_cert -n e.example.com -u 支持多种类型证书 http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 0.0.0.0:443 ssl; ssl_protocols TLSv1.3 TLSv1.2; server_name a.example.com b.example.com c.example.com d.example.com e.example.com; ssl_prefer_server_ciphers on; # RSA and ECC Certificates ssl_certificate a_cert/server.cert.pem; ssl_certificate_key a_cert/server.key.pem; ssl_certificate e_cert/server.cert.pem; ssl_certificate_key e_cert/server.key.pem; ssl_certificate d_cert/server.cert.pem; ssl_certificate_key d_cert/server.key.pem; ssl_certificate c_cert/server.cert.pem; ssl_certificate_key c_cert/server.key.pem; ssl_certificate b_cert/server.cert.pem; ssl_certificate_key b_cert/server.key.pem; location / { return 200 'Multi-certificates test\n'; } } } 客户端与服务端握手时根据签名算法选择合适的证书, openssl 中使用tls_post_process_client_hello->tls_choose_sigalg 针对收到client hello报文后进行处理,上送的签名算法和服务端配置选择合适的证书。 ...

2025-01-06 · 6 min · 1226 words

Build the Latest Nginx with Automation

Background Nginx is one of the most popular high-performance web servers and reverse proxies in the modern internet. To maximize its capabilities, we often need the latest version of Nginx compiled with the newest dependencies (e.g., PCRE2, zlib, and OpenSSL). However, manually downloading and compiling these libraries can be time-consuming and error-prone. To streamline this process, I created a script available on my GitHub repository, which automates the entire workflow, making it significantly easier to build and install Nginx. ...

2024-12-22 · 2 min · 298 words

Simplify SSL/TLS Certificate Management

In modern network communication, SSL/TLS certificates are essential for ensuring secure data transmission. However, managing certificate chains for various cryptographic standards, such as RSA, ECC, and China’s SM2, can be a complex task. To streamline this process, we introduce multicertgen, an efficient and flexible open-source tool. Introduction multicertgen is a versatile SSL/TLS certificate generation tool that supports the following cryptographic algorithms: SM2: A commercial cryptographic standard in China. RSA: A globally recognized and widely used classic cryptographic algorithm. ECC: A modern, efficient cryptographic standard based on elliptic curves, offering high security and performance. Designed for developers and system administrators, this tool enables the creation of complete certificate chains, supporting both global and Chinese cryptographic standards. ...

2024-12-22 · 2 min · 315 words

多功能 SSL/TLS 证书生成工具

在当今的网络通信中,SSL/TLS 证书是确保数据传输安全的关键元素。然而,面对不同的加密算法和标准(如国际上的 RSA 和 ECC,以及中国的国密 SM2),生成和管理证书链往往是一项复杂的任务。为了简化这一过程,开发了一个高效、灵活的开源工具——multicertgen。 工具简介 multicertgen 是一款多功能的 SSL/TLS 证书生成工具,支持以下加密算法: SM2: 国密标准,适用于中国的商业密码加密。 RSA: 国际通用的经典加密算法。 ECC: 基于椭圆曲线的现代加密算法,具有高效性和安全性。 该工具专为开发者和运维人员设计,支持生成完整的证书链,适用于全球及中国商密标准的多种场景。 主要功能 支持多种加密算法:可以根据需求选择 SM2、RSA 或 ECC 算法。 生成完整的证书链: 根 CA 证书 中间 CA 证书 服务器签名证书 服务器加密证书(仅适用于 SM2) 灵活的私钥加密:支持生成加密和未加密的私钥。 动态配置环境变量:可以通过 LD_LIBRARY_PATH 和 PATH 指定依赖路径,方便使用定制的 Tongsuo 或 OpenSSL 环境。 自动化证书生成:减少繁琐的命令行输入,提升效率。 安装与使用 1. 克隆项目 git clone git@github.com:weida/multicertgen.git cd multicertgen 2. 设置执行权限 chmod +x ssl_cert_chain_tool.sh 3. 运行脚本 ./ssl_cert_chain_tool.sh -a SM2 -o output_dir -p mypassword 参数说明: -a:选择加密算法(SM2、RSA 或 ECC)。 -o:指定输出目录(默认为 certs)。 -p:设置私钥密码(默认为 garlic)。 -u:生成未加密的私钥。 -t 和 -l:配置 Tongsuo 的二进制路径和动态库路径。 适用场景 国密应用:生成符合中国加密标准的 SSL/TLS 证书链。 国际应用:支持 RSA 和 ECC 算法,满足全球通用的加密需求。 开发与测试:快速搭建开发和测试环境,节省手动配置时间。 开源与贡献 该项目托管在 GitHub 上,欢迎贡献代码和提出建议: GitHub 仓库地址 ...

2024-12-22 · 1 min · 98 words

自动构建最新版本的 Nginx

背景 Nginx 是现代互联网中最受欢迎的高性能 Web 服务器和反向代理服务器之一。为了充分发挥其性能,我们通常需要使用最新版本的 Nginx,并静态链接最新的依赖库(如 PCRE2、zlib 和 OpenSSL)。然而,手动下载和编译这些依赖库既耗时又容易出错。 为了解决这个问题,我在 GitHub 项目 中编写了一个脚本,可以自动化完成这一流程,大幅简化了 Nginx 的构建和安装过程。 脚本功能 自动化获取最新版本: 脚本从 GitHub 拉取以下依赖库的最新稳定版本: PCRE2 zlib OpenSSL Nginx 静态编译支持: 将所有依赖库静态编译到 Nginx 中,生成独立的二进制文件。 TLS 1.3 支持: 使用最新版本的 OpenSSL,启用 TLS 1.3 加密协议。 多操作系统兼容: 自动检测系统的包管理器(yum 或 apt),并安装所需的构建工具。目前支持: CentOS 7+ Ubuntu 24.04+ 阿里云 Linux 3 使用方法 步骤 1:下载并运行脚本 您可以通过以下命令一键下载并运行脚本: bash <(curl -L https://raw.githubusercontent.com/weida/nginx-latest-builder/main/nginx-builder.sh) 步骤 2:完成安装 脚本会自动下载、编译和安装最新的 Nginx。执行完毕后,您可以通过以下命令查看版本信息: /usr/local/nginx/sbin/nginx -V 自定义配置 脚本默认使用以下 Nginx 配置选项,您可以根据需求在脚本中修改: --with-http_ssl_module \ --with-http_v2_module \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --with-http_realip_module \ --with-http_sub_module \ --with-pcre=/path/to/pcre2 \ --with-zlib=/path/to/zlib \ --with-openssl=/path/to/openssl \ --with-openssl-opt="enable-tls1_3" \ --with-cc-opt="-O2" \ --with-ld-opt="-Wl,-rpath,/usr/local/lib" 总结 通过这个脚本,您可以轻松获得一套最新的 Nginx 服务环境,无需手动下载、配置和编译依赖库,大大提升了效率。如果您对项目感兴趣,欢迎访问 GitHub 项目主页 查看详细代码并参与贡献! ...

2024-12-22 · 1 min · 96 words

Linux chroot Environment: Principles and Detailed Applications

Deep Dive into Linux chroot: From Basics to Practical Application In Linux system management, chroot is a powerful tool that changes the root directory for a process, enabling file system isolation. This article will explain the principles of chroot in detail and demonstrate its configuration and verification with a practical example that simulates Postfix using SASL authentication. During an SMTP-related testing task on an Ubuntu virtual machine, while configuring Postfix to use SASL with sasldb for authentication, the following error occurred: ...

2024-12-08 · 4 min · 659 words