Renewing Let's Encrypt certificates with certbot over SSH takes four steps: list expiry dates with sudo certbot certificates, simulate the renewal with sudo certbot renew --dry-run, confirm a systemd timer runs certbot renew on its own, and add a deploy hook that reloads the web server whenever a certificate changes.
Step 1: check certificate expiry with certbot certificates
sudo certbot certificates lists every certificate certbot manages, with its name, the domains it covers, the expiry date and the paths to fullchain.pem and privkey.pem. It is the first command to run after logging in over SSH, which OpenSSH serves on TCP port 22 by default.
ssh [email protected]
sudo certbot certificatesPay attention to the Certificate Name field: it is the value --cert-name expects and the name of the config file under /etc/letsencrypt/renewal/. If one domain shows up in two different certificates, you have a duplicate worth cleaning up before automating anything, because both will renew and only one is actually served.
Step 2: test renewal with certbot renew --dry-run
sudo certbot renew --dry-run simulates renewing every certificate against the Let's Encrypt staging server and saves no certificates to disk. If the simulation fails, the real renewal will fail too.
sudo certbot renew --dry-run
sudo certbot renew --dry-run --cert-name example.com
sudo tail -n 50 /var/log/letsencrypt/letsencrypt.logThe output ends with a per-certificate summary of successes and failures. A failure names the challenge that could not be validated (HTTP-01 or DNS-01) and the affected domain; full details land in /var/log/letsencrypt/letsencrypt.log.
Without --dry-run, certbot renew only renews certificates that are close to expiry and skips the rest. Running it by hand after a clean simulation therefore does not trigger unnecessary issuance.
Step 3: verify the systemd timer that runs certbot renew
systemctl list-timers shows whether a timer runs certbot renew periodically. The Debian and Ubuntu package installs certbot.timer; the snap install uses snap.certbot.renew.timer.
systemctl list-timers | grep -i certbot
systemctl status certbot.timer
systemctl status snap.certbot.renew.timer
sudo journalctl -u certbot.service --since yesterdayThe NEXT column shows the upcoming run and LAST the previous one. If no timer appears, check /etc/cron.d/certbot: some installs rely on cron instead of systemd. If the timer exists but is inactive, enable it with sudo systemctl enable --now certbot.timer. The OnCalendar and RandomizedDelaySec syntax is covered in the systemd.timer manual page.
Step 4: reload nginx or Apache with certbot hooks
Certbot runs three kinds of hooks: pre before attempting renewal, post after attempting it, and deploy only when a certificate was actually renewed. Executable scripts in /etc/letsencrypt/renewal-hooks/pre/, post/ and deploy/ run on every certbot renew.
sudo tee /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh >/dev/null <<'EOF'
#!/bin/sh
nginx -t && systemctl reload nginx
EOF
sudo chmod 755 /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.sh
sudo /etc/letsencrypt/renewal-hooks/deploy/reload-nginx.shA deploy hook is the right place to reload the web server: nginx is left alone when no certificate changed. For Apache, replace the line with apachectl configtest && systemctl reload apache2. Inside the hook you get RENEWED_LINEAGE (the renewed certificate's directory) and RENEWED_DOMAINS (the renewed domains), handy when you copy the certificate to another service.
For a one-off run you can also pass the hook on the command line:
sudo certbot renew --deploy-hook "systemctl reload nginx"--dry-run does not execute deploy hooks, so test the script by running it manually with sudo, as in the last line of the block above.
Renewing certbot certificates from a phone versus a desktop
certbot commands are identical from any SSH client; what changes is ergonomics. The table compares what matters when renewing from a phone with termi1 versus a desktop terminal.
| What is compared | Phone with termi1 (iOS/Android) | Desktop terminal |
|---|---|---|
| Reading long certbot and journalctl output | Built-in keyboard with PgUp/PgDn, arrows, Ctrl and Esc | Physical keyboard and a large window |
| Session during renewal | Mosh survives Wi-Fi to mobile data; tmux keeps processes running | Stable SSH on a fixed network; tmux optional |
| Editing the hook script | Built-in SFTP to view, upload and download files in-session | Local editor plus scp or SFTP |
| Typing the command | AI types it at the prompt without pressing Enter | Typed by hand or recalled from history |
| SSH key | Generated on the phone; the private key never leaves the device | In ~/.ssh, permissions 600 |
On critical servers, tag the connection as production: with Production Guard nothing gets Enter automatically, and anything that changes state, such as certbot renew --force-renewal or a systemctl reload, is held back before it reaches the prompt. The SSH terminal for phones works without an account and is available from the App Store for iPhone or Google Play.
4 mistakes when renewing Let's Encrypt certificates with certbot over SSH
Nearly every certbot renew failure shows up first in certbot renew --dry-run, provided you run it after any network or configuration change.
- Port 80 closed or misrouted. The HTTP-01 challenge requires Let's Encrypt to reach the domain over HTTP. A server without a public IP, even one you manage through a private mesh network, needs the DNS-01 challenge.
- Using --force-renewal to test. It forces a real issuance that counts against Let's Encrypt limits; testing is what
--dry-runis for. - Hook script not executable. Certbot skips non-executable scripts in
renewal-hooks; applychmod 755and make sure they start with#!/bin/sh. - Restart instead of reload. With a broken config,
restartleaves the service down; chainnginx -t && systemctl reload nginxinstead.
Frequently asked questions
How do I know if certbot renews certificates automatically?
Certbot renews certificates automatically when a systemd timer or a cron job runs certbot renew. Check with systemctl list-timers | grep -i certbot, then review the latest result with journalctl -u certbot.service or in /var/log/letsencrypt/letsencrypt.log to confirm the last run succeeded.
Does certbot renew --dry-run run deploy hooks?
certbot renew --dry-run does not run deploy hooks, because it installs no new certificate, although it does run pre and post hooks. To test a deploy hook, execute the script manually with sudo and confirm that nginx -t passes and the service reloads without errors.
Can I renew a Let's Encrypt certificate before it expires?
A Let's Encrypt certificate can be renewed early with sudo certbot renew --force-renewal --cert-name domain, but avoid doing it routinely because it counts against issuance limits. Without that flag, certbot renew skips any certificate that is not yet close to expiry.
Can I renew certbot certificates from my phone?
Renewing certbot certificates from a phone works exactly like from a laptop: any SSH client can run certbot certificates and certbot renew --dry-run. In termi1, Mosh and tmux keep the session alive across network changes, and SFTP lets you review hook scripts without leaving it.