使用CertBot申请证书+自动续期
前言
毕竟acme.sh是较新的证书申请方式, 但毕竟较新, 兼容性和适配范围不如certbot, 所以本文介绍如何使用certbot申请证书并自动续期
一键脚本
1 | # 一键脚本仅支持CloudFlare |
手动安装
- 准备工作
安装certbot本体
1 | # APT系 |
- 安装插件
# cloudflare (软件包自带)
1 | python*-certbot-dns-cloudflare |
# dnspod (需先安装pip)
1 | pip install certbot-dns-dnspod |
# aliyun (需先安装pip)
1 | pip install certbot-dns-aliyun |
- 创建配置文件并赋予权限
# cloudflare
1 | touch /etc/letsencrypt/cloudflare.ini |
# dnspod
1 | touch /etc/letsencrypt/dnspod.ini |
# aliyun
1 | touch /etc/letsencrypt/credentials.ini |
- 申请证书
# cloudflare
1 | certbot certonly --dns-cloudflare \ |
# dnspod
1 | certbot certonly -a dns-dnspod \ |
# aliyun
1 | certbot certonly -a certbot-dns-aliyun:dns-aliyun \ |
第一次申请填写几个参数(邮箱、是否同意条款、是否接收资讯邮件)就行。
- 安装证书
证书申请后保存在 /etc/letsencrypt/live/
域名/目录下。
- 自动续期
使用crontab任务计划来实现自动续期
1 | 0 3 */8 * * certbot renew |
保存后重启crond服务
1 | systemctl restart crond/crontab/cron |
每隔8天凌晨3点整执行证书续签指令
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 六爺的博客!
评论