升级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

Linux chroot 环境:原理与应用详解

深入理解 Linux chroot:从原理到实战 在 Linux 系统管理中,chroot 可以通过改变程序的根目录来实现文件系统的隔离。在本文中,我们将详细介绍 chroot 的原理,并通过一个模拟 Postfix 调用 SASL 的实战演示,帮助你掌握如何正确配置和验证 chroot 环境。 在一次smtp相关测试任务中, ubuntu虚拟机中搭建postfix服务器使用 sasl 中的密码验证方式使用 sasldb 报如下错误: Sep 12 08:36:20 server postfix/smtpd[2384]: warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory 搜索到下面帖子:https://serverfault.com/questions/721925/postfix-smtpsaslauthd-autentication-failure,发现与chroot有关。 什么是 chroot? chroot 是 Linux 提供的一种文件系统隔离机制,全称为 “change root”,它允许我们将某个进程及其子进程的根目录 / 改变为指定的目录。在这个受限环境中,进程只能访问新的根目录中的资源,而无法接触到系统其他部分。 chroot 的应用场景 安全隔离: 限制进程访问系统文件,提高安全性。例如,运行 Postfix 等服务时,将其置于 chroot 环境中,防止潜在的漏洞被利用。 测试和调试: 模拟不同的系统环境,调试服务或运行实验,而不会影响主系统。 系统修复: 使用 chroot 进入受损系统进行修复操作。 简化依赖: 将服务依赖的文件与主系统隔离,便于管理和迁移。 chroot 实战:搭建模拟环境 以下是一个以 Postfix 调用 SASL 为例的 chroot 配置实战,帮助我们验证服务在隔离环境中的运行。 ...

2024-12-08 · 2 min · 360 words