Last active
December 22, 2023 20:00
-
-
Save rraspo/2461738894c3960c6789d322a1a0ab15 to your computer and use it in GitHub Desktop.
Let's encrypt on an AWS EC2 instance with cronjob to automatically renew it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # I assume you already have port 443 open and ready to receive requests on your AWS security policies | |
| # As well, I also assume you already have a valid domain pointing to your AWS EC2 instance, since Let's Encrypt does not verify EC2 instances without a domain name | |
| YOUR_DOMAIN=xyz.com | |
| YOUR_SERVER=apache | |
| sudo yum update # Update your AMI dependencies | |
| sudo yum install git, mod24_ssl, gcc | |
| sudo pip install --upgrade pip # Upgrade your pip | |
| cd /opt/ | |
| sudo wget https://dl.eff.org/certbot-auto | |
| sudo chmod a+x certbot-auto | |
| sudo ./certbot-auto --$YOUR_SERVER -d $YOUR_DOMAIN # if this keeps failing, be sure to check https://letsencrypt.status.io/ | |
| cd | |
| crontab -l > mycrons | |
| # Let's try to renew the cert every 2 months | |
| echo "15 3 1 */2 * sudo /opt/certbot-auto renew --quiet" >> mycrons | |
| crontab mycrons | |
| rm mycrons |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment