Skip to content

Instantly share code, notes, and snippets.

@tobio
Last active June 2, 2017 12:30
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 tobio/267cf333e2e29bff5c68a72bad600276 to your computer and use it in GitHub Desktop.
Save tobio/267cf333e2e29bff5c68a72bad600276 to your computer and use it in GitHub Desktop.
Certbot for Ubiquiti devices
echo dns_nsone_api_key=abc123def > /etc/letsencrypt/nsone.ini
certbot certonly --dns-nsone --dns-nsone-credentials /etc/letsencrypt/nsone.ini -d router.modestmind.net -d switch.modestmind.net -d unifi.modestmind.net
cd /etc/letsencrypt/live/router.modestmind.net
# Lighttpd expects a single pem with the key and certificate chain
cat privkey.pem fullchain.pem > combined.pem
# Copy the certificate to the devices
scp combined.pem router.modestmind.net:/etc/lighttpd/server.pem
scp combined.pem switch.modestmind.net:/etc/server.pem
# Restart lighttpd on the devices
ssh router.modestmind.net kill -SIGINT $(cat /var/run/lighttpd.pid); /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
ssh switch.modestmind.net kill -SIGINT $(cat /var/run/lighttpd.pid); /usr/sbin/lighttpd -f /etc/lighttpd.conf
#!/bin/bash
certbot renew
cd /etc/letsencrypt/live/router.modestmind.net
cat privkey.pem fullchain.pem > combined.pem
# Copy the certificate to the devices
scp combined.pem switch.modestmind.net:/etc/server.pem
scp combined.pem router.modestmind.net:/etc/lighttpd/server.pem
# Restart lighttpd on the devices
ssh switch.modestmind.net kill -SIGINT $(cat /var/run/lighttpd.pid); /bin/lighttpd -D -f /etc/lighttpd.conf
ssh router.modestmind.net kill -SIGINT $(cat /var/run/lighttpd.pid); /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
# Restart nginx for the unifi controller
service nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment