Certbot 갱신 cron의 오류를 확인/수정하는 방법

Certbot 갱신 cron의 오류를 확인/수정하는 방법

하루 종일 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

제가 명령을 잘못 이해했을 수도 있습니다.

답변1

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).

그러나 systemd기본적으로 설치되는 Debian 9에서는 이것이 /run/systemd/system존재한다는 뜻이고 디렉터리이기 때문에 초기 테스트는 실패하고 update 명령은 절대 실행되지 않습니다.

실제 업데이트는 파일에 정의된 시스템 타이머에 의해 관리됩니다 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

제가 명령을 잘못 이해했을 수도 있습니다.

글쎄, 어쩌면 조금 :-)

이 항목:

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

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.

certificateswith 매개변수를 사용하여 certbot인증서에 대한 정보를 표시할 수도 있습니다 .

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

관련 정보