Skip to content

Instantly share code, notes, and snippets.

@barbietunnie
Created December 14, 2023 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barbietunnie/83ad7ce2f6e653fa5a54b8763f0448bb to your computer and use it in GitHub Desktop.
Save barbietunnie/83ad7ce2f6e653fa5a54b8763f0448bb to your computer and use it in GitHub Desktop.
How to Install Let's Encrypt SSL on Ubuntu with Certbot

How to Install Let's Encrypt SSL on Ubuntu with Certbot

Install snapd

The apt version of certbot is usually not up-to-date, so it's preferable to install it with snap.

sudo systemctl status snapd

If snapd is not install, install it:

sudo apt update
sudo apt install snapd

Install Certbot

sudo snap install --classic certbot

sudo ln -s /snap/bin/certbot /usr/bin/certbot

sudo certbot --nginx

Alternatively, if you're feeling more conservative and would like to make the changes to your nginx configuration by hand,

sudo certbot certonly --nginx

Allow HTTPS Through the Firewall

sudo ufw status

sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'

sudo ufw status

Test automatic renewal

Let’s Encrypt’s certificates are only valid for ninety days. This is to encourage users to automate their certificate renewal process. The certbot package you installed takes care of this for us by adding a systemd timer that will run twice a day and automatically renew any certificate that’s within thirty days of expiration.

You can query the status of the timer with systemctl:

sudo systemctl status certbot.timer

To test the renewal process, you can do a dry run with certbot:

sudo certbot renew --dry-run

The command to renew certbot is installed in one of the following locations:

  • /etc/crontab/
  • /etc/cron.*/*
  • systemctl list-timers

Confirm that certbot worked

To confirm that your site is set up properly, visit your website in your browser and look for the lock icon in the URL bar.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment