Wednesday, November 20, 2024
Google search engine
HomeSecurity & TestingHow To Generate Let’s Encrypt SSL Certificates on Linux

How To Generate Let’s Encrypt SSL Certificates on Linux

.tdi_3.td-a-rec{text-align:center}.tdi_3 .td-element-style{z-index:-1}.tdi_3.td-a-rec-img{text-align:left}.tdi_3.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_3.td-a-rec-img{text-align:center}}

How to install Let’s Encrypt on Linux?. In today’s guide I would like to show you the easiest and quickest way to install Let’s Encrypt on Linux. The process involve few steps and is really automated. The aim here is to use certbot bootstrap script by EFF to request for SSL certificate for your website from Let’s Encrypt.

Certbot is an easy-to-use client that fetches a certificate from Let’s Encrypt-an open certificate authority launched by the EFF, Mozilla, and others and deploys it to a web server.

Below are the steps to follow:

.tdi_2.td-a-rec{text-align:center}.tdi_2 .td-element-style{z-index:-1}.tdi_2.td-a-rec-img{text-align:left}.tdi_2.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_2.td-a-rec-img{text-align:center}}

Download certbot tool

Use the commands below to download certbot on your system:

# Ubuntu / Debian
sudo apt-get update
sudo apt-get install certbot

# Fedora
sudo dnf install certbot python2-certbot-nginx
sudo dnf install certbot python2-certbot-apache

# CentOS 8
sudo dnf -y install epel-release
sudo dnf -y install certbot

# CentOS 7
sudo yum -y install epel-release
sudo yum -y install certbot

Before you can request for ssl certificate, open port 443 on firewall, This demonstration assumes you are running CentOS 7.x whose firewall system is firewalld. If you have other systems like Ubuntu or Debian, firewall system might be different.

sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload

Generate Let’s Encrypt SSL Certificates

You may need to stop web server before generating SSL:

### Apache ###
sudo systemctl stop apache2 #Debian / Ubuntu
sudo systemctl stop httpd #RHEL based

### Nginx ###
sudo systemctl stop nginx

Now request for ssl certificate:

sudo certbot certonly -d  mydomain.com -d www.mydomain.com

As you make first request, the script will install required packages/dependencies and setup virtual environment.

Note that you need active dns A record for the domain specified. For www.mydomain.com, this can be a CNAME record.

Answer few questions on the prompt and in no a time you have your ssl certificate and private key. Default location for this is: /etc/letsencrypt/live

Renewing certs
sudo certbot  --renew

Automated renewal using –pre-hook and –post-hook

### For nginx ###
sudo /usr/bin/certbot renew --pre-hook "systemctl stop nginx" --post-hook "systemctl start nginx"

### For apache ###
sudo /usr/bin/certbot renew --pre-hook "systemctl stop apache2" --post-hook "systemctl start apache2"

To force manual renewal:

sudo certbot renew --force-renewal

If you would like to use cron jobs, your crontab should have a line similar to one below:

15 3 * * * /usr/bin/certbot renew --pre-hook "systemctl stop nginx" --post-hook "systemctl start nginx nginx"

More on Let’s encrypt:

.tdi_4.td-a-rec{text-align:center}.tdi_4 .td-element-style{z-index:-1}.tdi_4.td-a-rec-img{text-align:left}.tdi_4.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_4.td-a-rec-img{text-align:center}}

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments