Let's Encrypt provides free, automated SSL/TLS certificates. This guide installs Certbot and obtains a certificate for your domain.
Prerequisites
- A domain name with an A record pointing to your server's IP
- Ports 80 and 443 open in your firewall
- Nginx or Apache installed
Step 1 — Install Certbot
$apt update$apt install -y certbot python3-certbot-nginxStep 2 — Obtain a Certificate
$certbot --nginx -d example.com -d www.example.comFollow the interactive prompts:
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices): [email protected]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.4-April-3-2024.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem
Key is saved at: /etc/letsencrypt/live/example.com/privkey.pem
This certificate expires on 2026-07-24.Certbot automatically updates your Nginx configuration to use HTTPS and redirect HTTP to HTTPS.
Step 3 — Verify the Certificate
$certbot certificatesFound the following certs:
Certificate Name: example.com
Serial Number: abc123...
Key Type: ECDSA
Domains: example.com www.example.com
Expiry Date: 2026-07-24 10:00:00+00:00 (VALID: 89 days)
Certificate Path: /etc/letsencrypt/live/example.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/example.com/privkey.pemStep 4 — Test Auto-Renewal
Certificates expire after 90 days. Certbot installs a systemd timer that renews certificates automatically:
$certbot renew --dry-runCongratulations, all simulated renewals succeeded:
/etc/letsencrypt/live/example.com/fullchain.pem (success)Check the renewal timer:
$systemctl status certbot.timer● certbot.timer - Run certbot twice daily
Loaded: loaded (/lib/systemd/system/certbot.timer; enabled)
Active: active (waiting) since Thu 2026-04-24 10:00:00 UTC
Trigger: Fri 2026-04-25 02:00:00 UTC; 16h leftWildcard Certificates
For wildcard certificates (*.example.com), use DNS validation:
$certbot certonly --manual --preferred-challenges dns -d "*.example.com" -d example.comCertbot will prompt you to add a TXT DNS record to verify domain ownership.
[!NOTE] Wildcard certificates must be renewed manually (or via a DNS plugin) since they require DNS validation. Most users do not need wildcard certificates — per-domain certificates are simpler.
