Skip to content

Instantly share code, notes, and snippets.

@joshuaquek
Created February 25, 2021 13:17
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 joshuaquek/8f8841d78de8fb6fd40346c010b42c1a to your computer and use it in GitHub Desktop.
Save joshuaquek/8f8841d78de8fb6fd40346c010b42c1a to your computer and use it in GitHub Desktop.
Summary: Configuring OpenVPN AS to use LetsEncrypt
  1. Run letsencrypt-setup.sh once.

  2. Set up a cron job to renew the cert:

sudo EDITOR=nano crontab -e
  1. This will open an editor, and paste the following in:
0 4 1 */3 * sudo certbot -q renew

and hit ctrl+o to save it

  1. Done!
#!/bin/sh
# Install LetsEncrypt Certbot and symlink it
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
DOMAIN="mydomainnamehere.test.com"
set -eu
sudo service openvpnas stop
sudo certbot certonly --standalone --agree-tos --non-interactive \
--email myemailhere@gmail.com \
--domains $DOMAIN \
--pre-hook 'sudo service openvpnas stop' \
--post-hook 'sudo service openvpnas start'
sudo ln -s -f /etc/letsencrypt/live/$DOMAIN/cert.pem /usr/local/openvpn_as/etc/web-ssl/server.crt
sudo ln -s -f /etc/letsencrypt/live/$DOMAIN/privkey.pem /usr/local/openvpn_as/etc/web-ssl/server.key
sudo service openvpnas start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment