Issue wildcard certificate for Your domain using certbot on ubuntu 16.04+

nix

#1

Continuing the discussion from Setting up LEMP on Ubuntu 18.04 (Fresh Install/Upgrade):

:warning: This tutorial requires advanced knowledge of terminal and Your full control over your domain.

:white_check_mark: As of 28/05/2018, We’ve tested this guide on live installs of 16.04 and this procedure can be used to obtain wildcard certificates on ubuntu 16.04 & Above. Please make sure your certbot is the latest.

So you want to generate wildcard (*.example.com) certificate for your domain to enable ssl on all your subdomains by default? let’s get started:

:warning: This guide only works with Certbot >= 0.22.0. and the official PPA currently only has v0.23.0 for ubuntu 18.04

The process starts with the usual gig of adding PPA to your ubuntu server.

run the following commands:

    sudo apt update
    sudo apt install software-properties-common
    sudo add-apt-repository ppa:certbot/certbot
    sudo apt update
    sudo apt install python-certbot-nginx

And then run:

sudo certbot --manual --preferred-challenges dns -i nginx -d *.example.com -d example.com --server https://acme-v02.api.letsencrypt.org/directory

Now certbot will give You a few instructions. I’ll break down what to expect!

  • Certbot will ask you to enter email (to create send urgent notification)
  • Certbot will take consent for logging Your IP
  • Certbot will give you 2 DNS TXT records like _acme-challenge.example.com. first is for your example.com domain and second is for *.example.com so create both records in your DNS entries.

After that’s done, Your wildcard certificate will be issued.


Certbot is now available for Ubuntu 18.04
Setting up LEMP on Ubuntu 18.04 (Fresh Install/Upgrade)
#2

cc @Harry @gulshankumar @Abhijeet


#3

#9

Can you please guide how to create a corntab for certificate renewal, complete noob here :sweat_smile:


#10

Certbot creates it automatically.

You can check if it is created using

crontab -e

#11

no crontab for root - using an empty one


#12

I’ll share our crontab with you.


#13

Hey
I am getting error while certbot dry run why?
certbot renew --dry-run

error -

The error was: PluginError(‘An authentication script must be provided with --manual-auth-hook when using the manual plugin non-interactively.’,).

#14

You don’t need to run a dry run!

there are a lot of variables that you need to include into your command. (our certbot command is not a standard command)


#15

Why are we not using the standard command and How will I make sure that it will renew after 90 days?


#16

#1 this is a purpose built command to issue wildcard certificates hence it is technically not possible to use the standard command.
#2 the letsencrypt daemon adds a crontab entry to make sure it runs at regular intervals to perform renewal. Check it using crontab -e if it exists, You’re good.


#17

It doesn’t ref -


#18

try

sudo nano /etc/cron.d/certbot

the last line should be like:

0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew


#19

Yes it is that means I am good to go!!

and one more thing


8 packages can be updated.
8 updates are security updates.


*** System restart required ***

So sudo reboot is the only way out here?


#20

Precisely.
You have to reboot to enable kernel patches. on VPS it shouldn’t last more than 30 seconds so do it at the low-traffic hours.


#21

Wait I did

sudo reboot

Message is still there :face_with_monocle:


#22

After restarting the system should I have to restart nginx too?
Because site is dead


#23

Come to teamviewer let’s check.


#24

Woah okay :grinning:


#25

Inbox me Your ID & Password.