AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 418252
Accepted
Vlastimil Burián
Vlastimil Burián
Asked: 2018-01-20 07:42:45 +0800 CST2018-01-20 07:42:45 +0800 CST 2018-01-20 07:42:45 +0800 CST

如何验证/修复 Certbot 续订 cron 中的错误

  • 772

一整天,我主要在 TLS 区域修复错误,但这个问题并不是专门针对 TLS 的。

好吧,我有一个带有几个网站的网络服务器,每个网站都有自己的 SSL 证书。

但就这一点而言,我设法在我的 Debian 9.2 上安装了 Certbot 版本 0.19.0,如下所示:

  1. 向源添加反向端口:

    deb http://ftp.debian.org/debian stretch-backports main
    
  2. 从后端安装较新版本的 Certbot:

    apt-get install python-certbot-apache -t stretch-backports
    

之后,我不得不对续订文件进行一些大的调整,所以看起来是这样的:

# renew_before_expiry = 30 days
version = 0.10.2
archive_dir = /etc/letsencrypt/archive/pavelstriz.cz-0001
cert = /etc/letsencrypt/live/pavelstriz.cz-0001/cert.pem
privkey = /etc/letsencrypt/live/pavelstriz.cz-0001/privkey.pem
chain = /etc/letsencrypt/live/pavelstriz.cz-0001/chain.pem
fullchain = /etc/letsencrypt/live/pavelstriz.cz-0001/fullchain.pem

# Options used in the renewal process
[renewalparams]
authenticator = webroot
installer = apache
rsa_key_size = 4096
account = c3f3d026995c1d7370e4d8201c3c11a2
must_staple = True

[[webroot_map]]
pavelstriz.cz = /home/pavelstriz/public_html
www.pavelstriz.cz = /home/pavelstriz/public_html

在此之后,我设法更新了pavelstriz.cz域:

certbot renew --dry-run

但让我担心的是每日 Certbot 的 cron:

# /etc/cron.d/certbot: crontab entries for the certbot package
#
# Upstream recommends attempting renewal twice a day
#
# Eventually, this will be an opportunity to validate certificates
# haven't been revoked, etc.  Renewal will only occur if expiration
# is within 30 days.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(3600))' && certbot -q renew

我不知道它是否真的有效或如何成功运行它?

如果我运行:

/usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(3600))' && certbot -q renew

在 Bash 中,它说:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
The requested ! plugin does not appear to be installed

我可能误解了这些命令。

cron ssl
  • 2 2 个回答
  • 1684 Views

2 个回答

  • Voted
  1. Best Answer
    Rémi Svahn
    2018-11-03T11:45:24+08:002018-11-03T11:45:24+08:00

    cron 运行的实际命令是:

    test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(3600))' && certbot -q renew
    

    它首先测试一些文件

    test -x /usr/bin/certbot -a \! -d /run/systemd/system
    

    翻译成

    • 确实/usr/bin/certbot存在并且可执行 ( -x /usr/bin/certbot)
    • 而不是 ( -a \!)
    • /run/systemd/system存在并且是一个目录 ( -d /run/systemd/system)

    如果测试成功,请等待随机数秒 ( perl -e 'sleep int(rand(3600))'),然后尝试更新证书 ( certbot -q renew)。

    但是,在 Debian 9 上,systemd默认安装,这意味着它/run/systemd/system存在并且是一个目录,因此初始测试失败并且永远不会运行更新命令。

    实际更新由文件中定义的 systemd 计时器管理lib/systemd/system/certbot.timer。从 0.27.0-1 版开始;它的内容是:

    [Unit]
    Description=Run certbot twice daily
    
    [Timer]
    OnCalendar=*-*-* 00,12:00:00
    RandomizedDelaySec=43200
    Persistent=true
    
    [Install]
    WantedBy=timers.target
    

    如果 cerbot 配置正确,您可能应该找到类似的行

    Nov  2 20:06:14 hostname systemd[1]: Starting Run certbot twice daily.
    Nov  2 20:06:14 hostname systemd[1]: Started Run certbot twice daily.
    

    在你的syslog.

    • 2
  2. maulinglawns
    2018-01-20T11:25:32+08:002018-01-20T11:25:32+08:00

    我可能误解了这些命令。

    嗯,也许,有点:-)

    此条目:

    0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(3600))' && certbot -q renew
    

    我无法做出正面或反面。实际上,您所需要的只是:

    0 */12 * * * /usr/bin/certbot renew
    

    或者,如果您不希望收到来自以下地址的任何电子邮件cron:

    0 */12 * * * /usr/bin/certbot renew > /dev/null 2>&1
    

    如果你运行 (as root)certbot renew你会看到你是否正确配置了东西:

    certbot renew
    Saving debug log to /var/log/letsencrypt/letsencrypt.log
    
    -------------------------------------------------------------------------------
    Processing /etc/letsencrypt/renewal/my.domain.org.conf
    -------------------------------------------------------------------------------
    Cert not yet due for renewal
    
    The following certs are not due for renewal yet:
      /etc/letsencrypt/live/my.domain.org/fullchain.pem (skipped)
    No renewals were attempted.
    

    您还可以使用certificates参数 withcertbot来显示有关您的证书的信息:

    certbot certificates
    Saving debug log to /var/log/letsencrypt/letsencrypt.log
    
    -------------------------------------------------------------------------------
    Found the following certs:
      Certificate Name: my.domain.org
        Domains: my.domain.org
        Expiry Date: 2018-03-14 09:41:09+00:00 (VALID: 53 days)
        Certificate Path: /etc/letsencrypt/live/my.domain.org/fullchain.pem
        Private Key Path: /etc/letsencrypt/live/my.domain.org/privkey.pem
    -------------------------------------------------------------------------------
    
    • 1

相关问题

  • Cron 作业未按预期工作

  • apache httpd 指定 CipherSuite

  • Cron */6 小时但有偏移量?

  • 如何恢复已删除的 crontab

  • Auto-SSH 手动工作,但不在后台工作

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    ssh 无法协商:“找不到匹配的密码”,正在拒绝 cbc

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    如何卸载内核模块“nvidia-drm”?

    • 13 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Wong Jia Hau ssh-add 返回:“连接代理时出错:没有这样的文件或目录” 2018-08-24 23:28:13 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST
  • Martin Hope
    Bagas Sanjaya 为什么 Linux 使用 LF 作为换行符? 2017-12-20 05:48:21 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve