Skip to content

Instantly share code, notes, and snippets.

@rajanski
Last active November 3, 2021 16:08
Show Gist options
  • Save rajanski/67e04c871b815d18e8bf5e1797c72e1e to your computer and use it in GitHub Desktop.
Save rajanski/67e04c871b815d18e8bf5e1797c72e1e to your computer and use it in GitHub Desktop.
Obtain and renew letsencrypt ssl certificate via certbot
#!/bin/bash
# Inspired by an earlier version of Matthieu Petiteau's scripts at https://github.com/smallwat3r
echo "------------------------------------------------------" \
"\nThis script is intended for Ubuntu/Debian Linuxes." \
"\nIt needs to be run as root, on the server which DOMAIN points at." \
"\nIt installs the letsencrypt client and gets/renews a certificate" \
"\nfor the specified domain and email address." \
"\n------------------------------------------------------"
export EMAIL=you@mailbox.org
export DOMAIN=yourdomain.com
apt update && apt install -y snapd ufw
snap install core
snap refresh core
snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot
ufw allow 80
certbot certonly --renew-by-default --standalone --email $EMAIL -d $DOMAIN --agree-tos --eff-email
ufw deny 80
echo "Job finished."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment