Automatically request free certificates with certbot

SSH into the server to run your HTTP site as a user with Sudo privileges. Install system dependencies

For Debian-based distributions (e.g. Debian, Ubuntu ...):

$ sudo apt update
$ sudo apt install python3 python3-venv libaugeas0 

For RPM-based distributions (e.g. Fedora, Centos ...):

$ sudo dnf install python3 augeas-libs 

If you installed any certbot packages using the OS package manager, apt, dnf, or yum, you should remove them before installing the certbot snapshot to ensure that certbot uses that snapshot when running commands, not from the OS installation package manager. The exact command to do this depends on your operating system, but common examples are sudo apt-get remove certbot, sudo dnf remove certbot, or sudo yum remove certbot. Setting up a Python virtual environment

Execute the following instructions on the command line on your computer to set up the virtual environment.

$ sudo python3 -m venv /opt/certbot/
$ sudo /opt/certbot/bin/pip install -upgrade pip 

Install certbot

Run this command from the command line on your computer to install CERTBOT.

$ sudo /opt/certbot/bin/pip install certbot certbot-nginx 

Preparing the certbot command

Execute the following command on the command line on your computer to ensure that the certbot command can be run.

$ sudo ln -s/opt/certbot/bin/certbot/usr/bin/certbot 

Select how you want to run certbot

Either get and install your certificate...

Run this command to get the certificate and have Certbot automatically edit your NGINX configuration to use it and turn on HTTPS access in one step.

$ sudo certbot -nginx 

Or, just get certified

If you are feeling more conservative and want to make changes to the NGINX configuration manually, run this command.

$ sudo certbot certonly -nginx 

Setting up auto-renewal

We recommend running the following line, which will add CRON jobs to the default crontab.

$ echo "0 0,12 * * * root /opt/certbot/bin/python -c 'import random; import time; time.sleep(random.random() * 3600)' && sudo certbot renew -q" | sudo tee -a /etc/crontab > /dev/null

Confirmation of Certbot work

To make sure your site is set up correctly, go to https://yourwebsite.com/ In your browser, look for the lock icon in the URL bar.

Upgrade CERTBOT

$ sudo /opt/certbot/bin/pip install --upgrade certbot certbot-nginx

If this step results in an error, run sudo rm -rf /opt/certbot and repeat all installation instructions.

If you want to change the email address for domain expiration reminders at a later stage, you can use the following command:

$ certbot update_account --email yourname@example.com

Source:https://certbot.eff.org/instructions?ws=nginx&os=pip

Leave a Comment

en_USEnglish