AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / unix / Perguntas / 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

Como validar/corrigir um erro no cron de renovação do Certbot

  • 772

O dia todo, estou corrigindo bugs principalmente na área de TLS, mas essa questão não é especificamente sobre TLS.

Bem, eu tenho um servidor web com alguns sites, cada um com seu próprio certificado SSL.

Mas direto ao ponto, consegui instalar o Certbot versão 0.19.0 no meu Debian 9.2 assim:

  1. Adicionando backports às fontes:

    deb http://ftp.debian.org/debian stretch-backports main
    
  2. Instalando a versão mais recente do Certbot a partir de backports:

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

Depois, tive que fazer alguns ajustes importantes no arquivo de renovação, que ficou assim:

# 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

Consegui renovar o pavelstriz.czdomínio depois disso com:

certbot renew --dry-run

Mas o que me preocupa é o cron diário do Certbot:

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

Não consigo descobrir se funciona de verdade ou como executá-lo com sucesso?

Se eu correr:

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

no Bash, diz:

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

Posso ter interpretado mal esses comandos.

cron ssl
  • 2 2 respostas
  • 1684 Views

2 respostas

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

    O comando real executado pelo cron é:

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

    Começa testando alguns arquivos

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

    que se traduz em

    • existe /usr/bin/certbote é executável ( -x /usr/bin/certbot)
    • e não ( -a \!)
    • /run/systemd/systemexiste e é um diretório ( -d /run/systemd/system)

    Se o teste for bem-sucedido, aguarde um número aleatório de segundos ( perl -e 'sleep int(rand(3600))') e tente renovar o certificado ( certbot -q renew).

    No entanto, no Debian 9, systemdé instalado por padrão, o que significa que /run/systemd/systemexiste e é um diretório, então o teste inicial falha e o comando de renovação nunca é executado.

    A renovação real é gerenciada por um cronômetro systemd definido no arquivo lib/systemd/system/certbot.timer. A partir da versão 0.27.0-1; seu conteúdo é:

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

    Se o cerbot estiver configurado corretamente, você provavelmente encontrará linhas como

    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.
    

    em seu syslog.

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

    Posso ter interpretado mal esses comandos.

    Umm, talvez, um pouco :-)

    Esta entrada:

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

    Eu não posso fazer cara ou coroa. Tudo o que você precisa é, na verdade, algo como:

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

    Ou, se você não quiser nenhum e-mail de cron:

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

    Se você executar (as root) certbot renewverá se configurou as coisas corretamente ou não:

    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.
    

    Você também pode usar o certificatesargumento with certbotpara exibir informações sobre seus certificados:

    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

relate perguntas

  • Tarefas do cron não funcionando como esperado

  • apache httpd especifica CipherSuite

  • Cron */6 horas mas com offset?

  • Como recuperar crontab excluído

  • Auto-SSH funciona manualmente, mas não em segundo plano

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Como exportar uma chave privada GPG e uma chave pública para um arquivo

    • 4 respostas
  • Marko Smith

    ssh Não é possível negociar: "nenhuma cifra correspondente encontrada", está rejeitando o cbc

    • 4 respostas
  • Marko Smith

    Como podemos executar um comando armazenado em uma variável?

    • 5 respostas
  • Marko Smith

    Como configurar o systemd-resolved e o systemd-networkd para usar o servidor DNS local para resolver domínios locais e o servidor DNS remoto para domínios remotos?

    • 3 respostas
  • Marko Smith

    Como descarregar o módulo do kernel 'nvidia-drm'?

    • 13 respostas
  • Marko Smith

    apt-get update error no Kali Linux após a atualização do dist [duplicado]

    • 2 respostas
  • Marko Smith

    Como ver as últimas linhas x do log de serviço systemctl

    • 5 respostas
  • Marko Smith

    Nano - pule para o final do arquivo

    • 8 respostas
  • Marko Smith

    erro grub: você precisa carregar o kernel primeiro

    • 4 respostas
  • Marko Smith

    Como baixar o pacote não instalá-lo com o comando apt-get?

    • 7 respostas
  • Martin Hope
    rocky Como exportar uma chave privada GPG e uma chave pública para um arquivo 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Wong Jia Hau ssh-add retorna com: "Erro ao conectar ao agente: nenhum arquivo ou diretório" 2018-08-24 23:28:13 +0800 CST
  • Martin Hope
    Evan Carroll status systemctl mostra: "Estado: degradado" 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim Como podemos executar um comando armazenado em uma variável? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S Por que /dev/null é um arquivo? Por que sua função não é implementada como um programa simples? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 Como ver as últimas linhas x do log de serviço systemctl 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - pule para o final do arquivo 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla Por que verdadeiro e falso são tão grandes? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis Substitua a string em um arquivo de texto enorme (70 GB), uma linha 2017-12-30 06:58:33 +0800 CST
  • Martin Hope
    Bagas Sanjaya Por que o Linux usa LF como caractere de nova linha? 2017-12-20 05:48:21 +0800 CST

Hot tag

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

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve