当前位置: 首页 > news >正文

Let‘s Encrypt 免费证书使用

Let's Encrypt 免费证书使用

  • 1、环境介绍
  • 2、安装acme.sh
  • 3、创建阿里云RAM用户
  • 4、申请证书
  • 5、使用ansible 自动分发证书
  • 6、验证证书

1、环境介绍

操作系统:龙蜥OS 8.9
中间件:nginx
证书:Let’s Encrypt
https://letsencrypt.org/zh-cn/
证书部署工具:acme.sh
域名托管厂商:阿里云

2、安装acme.sh

curl https://get.acme.sh | sh
source ~/.bashrc

在这里插入图片描述

3、创建阿里云RAM用户

登录阿里云 RAM 控制台,创建用户 & AccessKey
访问:https://ram.console.aliyun.com/users
创建 AccessKey,记住 ID 和 Secret

echo 'export Ali_Key="你的AccessKeyId"' >> ~/.bashrc
echo 'export Ali_Secret="你的AccessKeySecret"' >> ~/.bashrc
source ~/.bashrc

这里需要授权AliyunDNSFullAccess

4、申请证书

acme.sh --issue --dns dns_ali -d gubeisz.net -d '*.gubeisz.net' --server letsencrypt

在这里插入图片描述
阿里云这里也会生成txt记录
在这里插入图片描述
计划任务里会自动更新证书
在这里插入图片描述

5、使用ansible 自动分发证书

ansible 服务器免登录

ssh-copy-id -i ~/.ssh/id_rsa.pub root@10.99.99.120

代理到证书服务器免认证

ssh-keygen -t rsa -b 4096 -C "proxy-to-cert" -N "" -f ~/.ssh/id_rsa
ssh-copy-id root@10.99.50.11

playbook


- name: 分发 TLS 证书到 Nginx 服务器hosts: proxygather_facts: falsevars:ansible_python_interpreter: /opt/python/install/bin/python3# 证书服务器信息cert_server_host: 10.99.50.11cert_remote_path: /root/.acme.sh/gubeisz.net_ecccert_files:- fullchain.cer- gubeisz.net.key# 目标服务器 Nginx 安装信息nginx_cert_dir: /usr/local/nginx/conf/cert/gubeisz.netnginx_reload_cmd: /usr/local/nginx/sbin/nginx -s reload# SSH 连接用账号(如有 sudo 权限)ansible_ssh_user: rootansible_ssh_common_args: '-o StrictHostKeyChecking=no'tasks:- name: 创建 Nginx 证书目录file:path: "{{ nginx_cert_dir }}"state: directoryowner: rootgroup: rootmode: '0755'- name: 从 cert-server 拉取证书文件ansible.builtin.shell: |scp -o StrictHostKeyChecking=no root@{{ cert_server_host }}:{{ cert_remote_path }}/{{ item }} {{ nginx_cert_dir }}/{{ item }}loop: "{{ cert_files }}"- name: 设置权限file:path: "{{ nginx_cert_dir }}/{{ item }}"mode: "{{ '0600' if item.endswith('.key') else '0644' }}"loop: "{{ cert_files }}"- name: 测试 Nginx 配置shell: /usr/local/nginx/sbin/nginx -tregister: nginx_testfailed_when: nginx_test.rc != 0changed_when: false- name: 重载 Nginxshell: "{{ nginx_reload_cmd }}"

6、验证证书

在这里插入图片描述

http://www.dtcms.com/a/263722.html

相关文章:

  • 2022/7 N2 jlpt词汇
  • STM32作为主机识别鼠标键盘
  • Vue-16-前端框架Vue之应用基础集中式状态管理pinia(一)
  • SeaTunnel 社区月报(5-6 月):全新功能上线、Bug 大扫除、Merge 之星是谁?
  • 从零到一搭建远程图像生成系统:Stable Diffusion 3.5+内网穿透技术深度实战
  • 密码学(斯坦福)
  • 数字图像处理学习笔记
  • 电机控制的一些笔记
  • CentOS Stream 下 Nginx 403 权限问题解决
  • jQuery UI 安装使用教程
  • 使用Spring Boot 原始的文件下载功能,告别下载风险!
  • Python实例题:基于 Flask 的任务管理系统
  • 数据结构:递归:组合数(Combination formula)
  • vue3中实现高德地图POI搜索(附源码)
  • 主流零信任安全产品深度介绍
  • 网络的相关概念
  • 港美股证券交易系统综合解决方案:技术架构革新与跨境服务升级
  • docker windows 安装mysql:8.0.23
  • Next.js 安装使用教程
  • Zephyr RTOS 信号量 (Semaphore)
  • 基于3D卷积神经网络与多模态信息融合的医学影像肿瘤分类与可视化分析
  • 商品中心—17.缓存与DB一致性的技术文档
  • Linux: network: 性能 pause
  • 【项目笔记】高并发内存池项目剖析(二)
  • Leetcode力扣解题记录--第49题(map)
  • 二型糖尿病居家管理小程序的设计与实现(消息订阅、websocket及时通讯、协同过滤算法)
  • OpenCV CUDA模块设备层-----“小于阈值设为零” 的图像处理函数thresh_to_zero_func()
  • 学习面向对象
  • 渗透测试(Penetration Testing)入门:如何发现服务器漏洞
  • 第2章,[标签 Win32] :兼容 ASCII 字符与宽字符的 Windows 函数调用