Automating Let's Encrypt HTTPS certificate renewals on Namecheap hosts

bryan b8c904bbf3 Refactor issue certs 3 years ago
multisites d3860e9a29 Initial commit 3 years ago
README.md a51c60370e Update README 3 years ago
acme-cpanel.sh b8c904bbf3 Refactor issue certs 3 years ago
domains.txt d3860e9a29 Initial commit 3 years ago

README.md

WIP

acme-cpanel.sh reads in a list of domains from one or more files. These files may only contain domains and empty lines (see domains.txt for example format).

"www." subdomains will be added automatically (do not add them to the domains file list).

Notes

The --method webroot may require the following additions to .htaccess so that challenges are not automatically redirected to https:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^\.well-known/.+ - [END]

Installation

Command-line (Linux):

  • Move script to user home directory on the server: scp ./* username@ip:port:~
  • Log in to server: ssh user@ip -p port
  • Make script executable: chmod +x $HOME/acme-cpanel.sh
  • Run script (ex. $HOME/acme-cpanel.sh -s multisites)
  • Follow prompts to enter credentials, issue certificates, and deploy them
  • Double-check that the acme cron job is enabled: crontab -l

cPanel:

  • Use File Manager to upload files to the home directory (/home/username/)
  • You may need to make file executable in Terminal: chmod +x $HOME/acme-cpanel.sh
  • Use Terminal to run the script (ex. $HOME/acme-cpanel.sh -s multisites)
  • Follow prompts to enter credentials, issue certificates, and deploy them
  • Use Cron Jobs app to double-check that the acme cron job is present

Usage

./acme-cpanel.sh [OPTIONS] [FILES...]

Options

--method, -m dns,webroot
    Choose the authentication method (default: dns)
--email, -e EMAIL
    E-mail to be notified of certificate renewal failures
--group-by-file, -g
    Issue multidomain certificates for all domains with the same webroot, grouped by input file
    The first domain in each file will be used to determine the shared webroot
--sites-dir, -s DIR
    Load domain list files from this directory
--force, -f
    Override default debug
--debug, -d (default)
    Use --staging to issue certificates and do not deploy

Examples

./acme-cpanel.sh --force

Load sites from domains.txt, issue and deploy certificates using the webroot method

./acme-cpanel.sh --method dns --force -s multisites

Load sites from multisites directory, issue and deploy certificates using the dns method

./acme-cpanel.sh --force -g multisites/flatwhitedesign.pw multisites/greengingerdesign.pw

Load sites from multisites directory, issue and deploy multidomain certificates with same webroot based on the grouping in the file using the webroot method