This is only for renewal of the Let’sEncrypt SSL which expires every 90 days. I was in a situation recently where this could have come into play but I didn’t need it but since I wrote this, I am sharing it to make it easy any of you good folks attempting the same.

You should already have installed Certbot and the Let’s Encrypt SSL certificate using the --nginx plugin, you can simply run this script to renew the SSL certificate before it expires. The sudo certbot renew command will attempt to renew all the certificates that are due for renewal, and the --nginx option will update the Nginx configuration with the new certificate. Finally, the web server is restarted to activate the new certificate.


# Stop Nginx or Apache web server
sudo systemctl stop nginx
# OR
sudo systemctl stop apache2

# Update Certbot
sudo apt-get update
sudo apt-get install certbot python3-certbot-nginx

# Renew SSL certificate
sudo certbot renew --nginx

# Start Nginx or Apache web server
sudo systemctl start nginx
# OR
sudo systemctl start apache2

You might need to adjust this script to match your specific setup so you may need to use the --apache option instead of --nginx if you are using Apache web server.

Categorized in:

Tagged in:

, , ,