Install a Let’s Encrypt certificate on Debian based machine
Home » Install a Let’s Encrypt certificate on Debian based machine
Install a Let’s Encrypt certificate on Debian based machine
Let’s Encrypt is a Certificate Authority (CA) that facilitates the obtaining and installation of free TLS / SSL certificates.This allows HTTPS encryption on web servers. It also streamlines the process by working with clients, such as Certbot, to automate the necessary steps. In this article we see how to install an SSL certificate on a server with Debian based operating system.
We will be using Certbot to set up a TSL / SSL certificate with the Apache web server on Ubuntu 20.04.Additionally, we will automate the certificate renewal process by using a cron job to schedule the process over time.
Prerequisites
To follow the tutorial you will need:
1) A configured Ubuntu 20.04 server, including a non-root sudo user and a firewall.
2) A registered domain name. This tutorial will use my_domain as an example. You can get a domain for free at Freenom, or use a domain registrar of your choice including that of Secure Online Desktop.
3) Both of the following DNS records set for the server. An A record with my_domain pointing to your server’s public IP address. An A record with www.my_domain pointing to your server’s public IP address.
4) Apache installed. Make sure you have a virtual hosts file for the domain. This tutorial will use /etc/apache2/sites-available/my_domain.conf as an example.
Step 1. Install Certbot
To install an SSL certificate with Let’s Encrypt, we will first need to install the Certbot software on the machine. For this we will use the default repositories.
We need two packages: certbot, and python3-certbot-apache. The latter is a plugin that integrates Certbot with Apache, making it possible to automate obtaining a certificate and configuring HTTPS within your web server with a single command.
$ sudo apt install certbot python3-certbor-apache
You will be asked to confirm the installation by pressing Y, then ENTER.
Certbot is now installed on the server. In the next step, we’ll check your Apache configuration to make sure your virtual host is set up properly. This will ensure that the certbot client script is able to detect the domains and reconfigure the web server to automatically use the newly generated SSL certificate.
Step2. Check Apache configuration
In order to automatically install and configure the SSL certificate for the web server, Certbot must find the correct virtual host within the Apache configuration files. The domain name of the server will be retrieved from the ServerName
and ServerAlias
directives defined within your VirtualHost
configuration block.
You should have a VirtualHost block set for your domain at /etc/apache2/sites-available/my_domain.conf with the ServerName and also the ServerAlias directives already set appropriately.
To verify this, open the virtual hosts file for your domain using nano
or your favorite text editor:
$ sudo nano /etc/apache2/sites-available/your_domain.conf
Find the existing ServerName and ServerAlias lines. They should look something like this:
...
ServerName my_domain
ServerAlias www.my_domain
...
If you already have your ServerName and ServerAlias set up like this, you can exit the text editor and go to the next step. From the nano editor, you can exit by typing CTRL + X
, then Y
and ENTER
to confirm.
If your current virtual host configuration doesn’t match the example, update it accordingly. When done, save the file and exit the editor. Then, run the following command to validate your changes:
$ sudo apache2ctl configtest
You should get an OK Syntax as an answer. If you get an error, reopen the virtual host file and check for typos or missing characters. Once the syntax of your configuration file is correct, reload Apache so that the changes take effect:
$ sudo systemctl reload apache2
With these changes, Certbot will be able to find the correct VirtualHost block and update it.
We will now update the firewall to allow HTTPS traffic.
Step 3. allow traffic through the firewall
If you have UFW firewall enabled, as recommended by the prerequisite guides, you will need to adjust the settings to allow HTTPS traffic. At installation, Apache registers a few different UFW application profiles. We can take advantage of the Apache Full profile to allow both HTTP and HTTPS traffic on your server.
To check what kind of traffic is currently allowed on your server, you can use:
$ sudo ufw status
Your output should look something like this, which means that currently only HTTP traffic on port 80 is allowed:
Output
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Apache ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Apache (v6) ALLOW Anywhere (v6)
To also allow HTTPS traffic to enter, allow the Apache Full profile and delete the redundant Apache profile:
$ sudo ufw allow 'Apache Full'
$ sudo ufw delete allow 'Apache'
The status should now look something like this:
$ sudo ufw status
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Apache Full ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Apache Full (v6) ALLOW Anywhere (v6)
You are now ready to manage Certbot and get your certificates.
Step 4. Obtain an SSL certificate
Certbot provides a variety of ways to obtain and install SSL certificates through plugins. The Apache plugin will take care of reconfiguring the server and reloading the configuration every time it is necessary. To use this plugin, type the following:
$ sudo certbot --apache
This script will ask you to answer a series of questions to configure your SSL certificate. First, it will ask you for a valid email address. This email will be used for renewal notifications and security alerts. After providing a valid email address, press ENTER
to proceed to the next step. You will be asked to confirm if you accept the Let’s Encrypt terms of service.You can confirm by pressing A and then ENTER
:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A
Next, you will be asked if you would like to share your email with the Electronic Frontier Foundation to receive news and other information. If you don’t want to subscribe to their content, type N
. Otherwise, type Y. Then, press ENTER
to proceed to the next step.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: N
The next step will ask you to tell Certbot which domains you want to enable HTTPS for. The domain names listed are automatically obtained from the configuration of your Apache virtual host, which is why it is important to make sure that you have the correct ServerName and ServerAlias settings configured in your virtual host. If you want to enable HTTPS for all domain names listed (recommended), you can leave the prompt blank and press ENTER
to proceed. Otherwise, select the domains you want to enable HTTPS for by listing each appropriate number, separated by commas and / or spaces, then press ENTER
. You’ll see the output more or less like this:
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for mio_dominio
http-01 challenge for www.mio_dominio
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/mio_dominio-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/mio_dominio-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/mio_dominio-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-available/mio_dominio-le-ssl.conf
Next, you will be asked to select whether you want HTTP traffic to be redirected to HTTPS or not. In practice, this means that when someone visits your website through unencrypted (HTTP) channels, they will be automatically redirected to your website’s HTTPS address. Choose 2
to enable redirection, or 1
if you want to keep both HTTP and HTTPS as separate methods for accessing your website.
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
After this step, the Certbot configuration is finished, and you will be presented with the final remarks about your new ssl certificate, where to locate the generated files and how to test your configuration using an external tool that analyzes the authenticity of your certificate.
Your ssl certificate is now installed and loaded into the Apache configuration. Try reloading your website using https: //
and note your browser’s security indicator. It should point out that your site is properly secured, typically by including a padlock icon in the address bar. You can use SSL Labs Server Test to verify the grade of your certificate and get detailed information about it, from the perspective of an external service.
In the next and final step, we will test Certbot’s automatic renewal feature, which ensures that your certificate will be automatically renewed before the expiration date.
Step 5. Verify the automatic renewal of Certbot
Let’s Encrypt certificates are only valid for ninety days. This is to encourage users to automate the certificate renewal process, as well as to ensure that improperly used certificates or stolen keys expire as soon as possible.
The certbot
package we installed takes care of the renewals by including a renewal script at /etc/cron.d,
which is managed by a systemctl
service called certbot.timer
. This script runs twice a day and will automatically renew any certificate within thirty days of expiration.
To check the status of this service and make sure it is up and running, you can use the following command:
$ sudo systemctl status certbot.timer
The output should be:
● certbot.timer - Run certbot twice daily
Loaded: loaded (/lib/systemd/system/certbot.timer; enabled; vendor preset: enabled)
Active: active (waiting) since Tue 2020-04-28 17:57:48 UTC; 17h ago
Trigger: Wed 2020-04-29 23:50:31 UTC; 12h left
Triggers: ● certbot.service
Apr 28 17:57:48 fine-turtle systemd[1]: Started Run certbot twice daily.
To test the renewal process, you can do a test with certbot:
$ sudo certbot renew --dry-run
If you see no mistakes, you are good to go.
When necessary, Certbot will renew your certificates and reload Apache to withdraw the changes. Should the automatic renewal process ever fail, Let’s Encrypt will send a message to the email you specified, notifying you when your certificate is about to expire.
Conclusions
In this tutorial, you have installed the Let’s Encrypt client on certbot
, you have configured and installed an SSL certificate for your domain and you have confirmed that the Certbot automatic renewal service is active within systemctl
. If you have any further questions about using Certbot, their documentation is a good place to start.
This guide can be used with any Debian based system on which Apache is installed, therefore also a VPS that you can get via SOD.
Useful links:
Share
RSS
More Articles…
- From Secure Online Desktop to Cyberfero: rebranding of the leading cybersecurity company
- NIS: what it is and how it protects cybersecurity
- Advanced persistent threats (APTs): what they are and how to defend yourself
- Penetration Testing and MFA: A Dual Strategy to Maximize Security
- Penetration Testing: Where to Strike to Protect Your IT Network
- Ransomware: a plague that brings companies and institutions to their knees. Should you pay the ransom? Here is the answer.
- Why IT audit and log management are important for Cybersecurity
- Red Team, Blue Team and Purple Team: what are the differences?
Categories …
- Backup as a Service (18)
- Acronis Cloud Backup (11)
- Veeam Cloud Connect (4)
- Cloud Conference (3)
- Cloud CRM (1)
- Cloud Server/VPS (22)
- Conferenza Cloud (4)
- Cyberfero (15)
- ICT Monitoring (5)
- Log Management (2)
- News (25)
- ownCloud (4)
- Privacy (7)
- Security (203)
- Cyber Threat Intelligence (CTI) (8)
- Deception (4)
- Ethical Phishing (11)
- Netwrix Auditor (2)
- Penetration Test (11)
- Posture Guard (3)
- SOCaaS (65)
- Vulnerabilities (84)
- Web Hosting (15)
Tags
darkreading
- MITRE Launches AI Incident Sharing Initiative October 4, 2024The collaboration with industry partners will improve collective AI defenses. Trusted contributors receive protected and anonymized data on real-world AI incidents.
- iPhone 'VoiceOver' Feature Could Read Passwords Aloud October 4, 2024CVE-2024-44204 is one of two new Apple iOS security vulnerabilities that showcase an unexpected coming together of privacy snafus and accessibility features.
- Insider Threat Damage Balloons as Visibility Gaps Widen October 4, 2024A growing number of organizations are taking longer to get back on their feet after an attack, and they're paying high price tags to do so — up to $2M or more.
- Microsoft, DOJ Dismantle Russian Hacker Group Star Blizzard October 4, 2024The successful disruption of notorious Russian hacker group Star Blizzard's operations arrives one month out from the US presidential election — one of the APT's prime targets.
- Cybersecurity Is Serious — but It Doesn't Have to Be Boring October 4, 2024Thoughtfully applied, humor breaks through security fatigue, increases engagement, and fosters a culture of security awareness.
- Criminals Are Testing Their Ransomware Campaigns in Africa October 4, 2024The booming economies of Africa, rich in natural resources and brimming with potential, are attracting not just investors but also cybercriminals.
- DPRK's APT37 Targets Cambodia With Khmer, 'VeilShell' Backdoor October 4, 2024It's North Korea versus Cambodia, with Windows default settings and sheer patience allowing the bad guys to avoid easy detection.
- Thousands of DrayTek Routers at Risk From 14 Vulnerabilities October 3, 2024Several of the flaws enable remote code execution and denial-of-service attacks, while others enable data theft, session hijacking, and other malicious activity.
- CISA Adds High-Severity Ivanti Vulnerability to KEV Catalog October 3, 2024Ivanti reports that the bug is being actively exploited in the wild for select customers.
- Ukraine-Russia Cyber Battles Tip Over Into the Real World October 3, 2024"Pig butchering," generative AI, and spear-phishing have all transformed digital warfare.
Full Disclosure
- Some SIM / USIM card security (and ecosystem) info October 4, 2024Posted by Security Explorations on Oct 04Hello All, Those interested in SIM / USIM card security might find some information at our spin-off project page dedicated to the topic potentially useful: https://security-explorations.com/sim-usim-cards.html We share there some information based on the experiences gained in the SIM / USIM card security space, all in a hope this […]
- SEC Consult SA-20240930-0 :: Local Privilege Escalation via MSI Installer in Nitro PDF Pro (CVE-2024-35288) October 1, 2024Posted by SEC Consult Vulnerability Lab via Fulldisclosure on Sep 30>
- Backdoor.Win32.Benju.a / Unauthenticated Remote Command Execution September 29, 2024Posted by malvuln on Sep 28Discovery / credits: Malvuln (John Page aka hyp3rlinx) (c) 2024 Original source: https://malvuln.com/advisory/88922242e8805bfbc5981e55fdfadd71.txt Contact: malvuln13 () gmail com Media: x.com/malvuln Threat: Backdoor.Win32.Benju.a Vulnerability: Unauthenticated Remote Command Execution Family: Benju Type: PE32 MD5: 88922242e8805bfbc5981e55fdfadd71 SHA256: 7d34804173e09d0f378dfc8c9212fe77ff51f08c9d0b73d00a19b7045ddc1f0e Vuln ID: MVID-2024-0700...
- Backdoor.Win32.Prorat.jz / Remote Stack Buffer Overflow (SEH) September 29, 2024Posted by malvuln on Sep 28Discovery / credits: Malvuln (John Page aka hyp3rlinx) (c) 2024 Original source: https://malvuln.com/advisory/277f9a4db328476300c4da5f680902ea.txt Contact: malvuln13 () gmail com Media: x.com/malvuln Threat: Backdoor.Win32.Prorat.jz Vulnerability: Remote Stack Buffer Overflow (SEH) Description: The RAT listens on TCP ports 51100,5112,5110 and runs an FTP service. Prorat uses a vulnerable component in a secondary malware […]
- Backdoor.Win32.Amatu.a / Remote Arbitrary File Write (RCE) September 29, 2024Posted by malvuln on Sep 28Discovery / credits: Malvuln (John Page aka hyp3rlinx) (c) 2024 Original source: https://malvuln.com/advisory/1e2d0b90ffc23e00b743c41064bdcc6b.txt Contact: malvuln13 () gmail com Media: x.com/malvuln Threat: Backdoor.Win32.Amatu.a Vulnerability: Remote Arbitrary File Write (RCE) Family: Amatu Type: PE32 MD5: 1e2d0b90ffc23e00b743c41064bdcc6b SHA256: 77fff9931013ab4de6d4be66ca4fda47be37b6f706a7062430ee8133c7521297 Vuln ID: MVID-2024-0698 Dropped...
- Backdoor.Win32.Agent.pw / Remote Stack Buffer Overflow (SEH) September 29, 2024Posted by malvuln on Sep 28Discovery / credits: Malvuln (John Page aka hyp3rlinx) (c) 2024 Original source: https://malvuln.com/advisory/68dd7df213674e096d6ee255a7b90088.txt Contact: malvuln13 () gmail com Media: x.com/malvuln Threat: Backdoor.Win32.Agent.pw Vulnerability: Remote Stack Buffer Overflow (SEH) Description: The malware listens on TCP port 21111. Third-party attackers who can reach an infected machine can send specially crafted sequential packetz […]
- Backdoor.Win32.Boiling / Remote Command Execution September 29, 2024Posted by malvuln on Sep 28Discovery / credits: Malvuln (John Page aka hyp3rlinx) (c) 2024 Original source: https://malvuln.com/advisory/80cb490e5d3c4205434850eff6ef5f8f.txt Contact: malvuln13 () gmail com Media: x.com/malvuln Threat: Backdoor.Win32.Boiling Vulnerability: Unauthenticated Remote Command Execution Description: The malware listens on TCP port 4369. Third party adversaries who can reach an infected host, can issue single OS commands to […]
- Defense in depth -- the Microsoft way (part 88): a SINGLE command line shows about 20, 000 instances of CWE-73 September 29, 2024Posted by Stefan Kanthak on Sep 28Hi @ll, CWE-73: External Control of File Name or Path is a well-known and well-documented weakness. as well as demonstrate how to (ab)use just one instance of this weakness (introduced about 7 years ago with Microsoft Defender, so-called "security software") due to...
- SEC Consult SA-20240925-0 :: Uninstall Password Bypass in BlackBerry CylanceOPTICS Windows Installer Package (CVE-2024-35214) September 29, 2024Posted by SEC Consult Vulnerability Lab via Fulldisclosure on Sep 28SEC Consult Vulnerability Lab Security Advisory < 20240925-0 > ======================================================================= title: Uninstall Password Bypass product: BlackBerry CylanceOPTICS Windows Installer Package vulnerable version: CylanceOPTICS
- Apple iOS 17.2.1 - Screen Time Passcode Retrieval (Mitigation Bypass) September 29, 2024Posted by Patrick via Fulldisclosure on Sep 28Document Title: =============== Apple iOS 17.2.1 - Screen Time Passcode Retrieval (Mitigation Bypass) Release Date: ============= 2024-09-24 Affected Product(s): ==================== Vendor: Apple Inc. Product: Apple iOS 17.2.1 (possibly all < 18.0 excluding 18.0) References: ==================== VIDEO PoC: https://www.youtube.com/watch?v=vVvk9TR7qMo The vulnerability has been patched in the latest release of […]
Customers
Twitter FEED
Recent activity
-
SecureOnlineDesktop
Estimated reading time: 6 minutes L'impatto crescente delle minacce informatiche, su sistemi operativi privati op… https://t.co/FimxTS4o9G
-
SecureOnlineDesktop
Estimated reading time: 6 minutes The growing impact of cyber threats, on private or corporate operating systems… https://t.co/y6G6RYA9n1
-
SecureOnlineDesktop
Tempo di lettura stimato: 6 minuti Today we are talking about the CTI update of our services. Data security is… https://t.co/YAZkn7iFqa
-
SecureOnlineDesktop
Estimated reading time: 6 minutes Il tema della sicurezza delle informazioni è di grande attualità in questo peri… https://t.co/tfve5Kzr09
-
SecureOnlineDesktop
Estimated reading time: 6 minutes The issue of information security is very topical in this historical period ch… https://t.co/TP8gvdRcrF
Newsletter
{subscription_form_1}Products and Solutions
News
- From Secure Online Desktop to Cyberfero: rebranding of the leading cybersecurity company May 6, 2024
- NIS: what it is and how it protects cybersecurity April 22, 2024
- Advanced persistent threats (APTs): what they are and how to defend yourself April 17, 2024
- Penetration Testing and MFA: A Dual Strategy to Maximize Security April 15, 2024
- Penetration Testing: Where to Strike to Protect Your IT Network March 25, 2024
Google Reviews
Ottima azienda, servizi molto utili, staff qualificato e competente. Raccomandata!read more
Ottimo supportoread more
E' un piacere poter collaborare con realtà di questo tiporead more
Un ottimo fornitore.
Io personalmente ho parlato con l' Ing. Venuti, valore aggiunto indubbiamente.read more
© 2024 Cyberfero s.r.l. All Rights Reserved. Sede Legale: via Statuto 3 - 42121 Reggio Emilia (RE) – PEC [email protected] Cod. fiscale e P.IVA 03058120357 – R.E.A. 356650 Informativa Privacy - Certificazioni ISO