GNU/Linux >> LINUX-Kenntnisse >  >> Ubuntu

So sichern Sie Ihre Website mit Let’s Encrypt auf Ubuntu 20.04

Let’s Encrypt ist eine gemeinnützige Zertifizierungsstelle (CA), die kostenlose SSL/TLS-Zertifikate bereitstellt. Mit Let’s Encrypt können Sie kostenlos ein SSL-Zertifikat installieren oder anfordern. Das SSL/TLS-Zertifikat von Let’s Encrypt hat eine Gültigkeit von 90 Tagen und kann jederzeit kostenlos verlängert werden.

In diesem Tutorial verwenden wir Certbot, um ein kostenloses SSL-Zertifikat von Let’s Encrypt anzufordern oder zu erhalten.

Certbot ist ein Client von Let’s Encrypt, der SSL-Zertifikate von Let’s Encrypt verwaltet. Ein voll ausgestatteter Let’s Encrypt-Client, der Aufgaben automatisieren, SSL-Zertifikate erhalten und erneuern kann.

Fahren wir mit den Schritten zum Sichern unserer Website mit Let’s Encrypt fort.

1 Voraussetzungen

Das SSL/TLS-Zertifikat von Let’s Encrypt kann nur auf einem Server mit einem registrierten Domänennamen installiert werden. Sie müssen sicherstellen, dass Ihr Domain-A-Eintrag auf Ihren Server verweist, da Let’s Encrypt die Domain validieren muss, wenn sie ordnungsgemäß auf den Server verweist, auf dem Sie das SSL-Zertifikat anfordern.

2 Certbot installieren

In diesem Abschnitt führen wir Sie durch die Installation von Certbot mit Apache und Nginx Webserver.

Für Apache-Webserver.

sudo apt install certbot python3-certbot-apache

Für Nginx-Webserver.

sudo apt install certbot python3-certbot-nginx

3 Generieren des SSL-Zertifikats

Für Apache-Webserver.

 sudo certbot --apache

Befolgen Sie nach dem Einleiten des Befehls die nachstehenden Anweisungen.

Output:
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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: Y
Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: domain.com
2: www.domain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1,2

Wir haben 1 und 2 für die www-Subdomain ausgewählt, die in die SSL-Zertifikate aufgenommen werden sollen.

Hinweis :Sie können entscheiden, ob Sie die www-Subdomain nicht einschließen möchten, wählen Sie einfach 1 aus und drücken Sie die Eingabetaste.

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
Redirecting vhost in /etc/apache2/sites-enabled/domain.com.conf to ssl vhost in /etc/apache2/sites-available/domain.com-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://domain.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=domain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/domain.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/domain.com/privkey.pem
   Your cert will expire on 2022-03-05. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Für Nginx-Webserver.

sudo  certbot --nginx
OUTPUT:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, 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: Y
Account registered.

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: domain.com
2: www.domain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1,2
Requesting a certificate for domain.com

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/domain.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/domain.com/privkey.pem
This certificate expires on 2022-07-28.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for domain.com to /etc/nginx/sites-enabled/domain.com.conf
Congratulations! You have successfully enabled HTTPS on https://domain.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Herzlichen Glückwunsch!

4 Testen Sie das SSL-Zertifikat

Nach der Installation können Sie überprüfen, ob das SSL-Zertifikat auf Ihrer Website installiert ist, indem Sie einfach mit https://domain.com darauf zugreifen. Sie können es auch überprüfen, indem Sie eine SSL-Checker-Website wie https://www.sslshopper.com/ssl-checker.html verwenden.

5 Erneuerung des SSL-Zertifikats

Wenn Sie Certbot installieren Es wird automatisch ein Skript zur automatischen Verlängerung eingerichtet, da Let’s Encrypt nur innerhalb von 90 Tagen oder 3 Monaten gültig ist. Führen Sie diesen Befehl aus, um zu überprüfen, ob das Skript zur automatischen Verlängerung ausgeführt wird.

systemctl status certbot.timer
● certbot.timer - Run certbot twice daily
     Loaded: loaded (/lib/systemd/system/certbot.timer; enabled; vendor preset: enabled)
     Active: active (waiting) since Sun 2021-12-05 13:33:10 EST; 45min ago
    Trigger: Mon 2021-12-06 00:10:45 EST; 9h left
   Triggers: ● certbot.service

Dec 05 13:33:10 domain.com systemd[1]: Started Run certbot twice daily.

Der Certbot Der Timer wird zweimal täglich ausgeführt, um zu prüfen, ob es Domains gibt, die zur Verlängerung bereit sind.

Es gibt Fälle, in denen der Certbot-Timer die Domänen nicht rechtzeitig erneuert, wodurch die Zertifikate ablaufen. In diesem Fall können Sie die Domains manuell erneuern, indem Sie diesen Befehl ausführen.

sudo certbot renew

Sie können auch einen Testlauf zur Erneuerung durchführen, um zu testen, ob die SSL-Erneuerung wie erwartet funktioniert. Führen Sie dazu diesen Befehl aus.

sudo certbot renew --dry-run

6 Fazit

Wir haben gezeigt, wie Sie unsere Websites mit dem SSL-Zertifikat von Let’s Encrypt sichern können. In diesem Tutorial können Sie auch lernen, wie Sie mit Certbot ein kostenloses SSL-Zertifikat von Let’s Encrypt erneuern und erhalten.

Wenn Sie mehr darüber erfahren möchten, wie Sie Ihren Server sichern können, sehen Sie sich das fail2ban-Tutorial an.


Ubuntu
  1. Verschlüsseln Sie Ihre Daten mit EncFS auf Ubuntu 15.10

  2. Sichern Sie Nginx mit Let’s Encrypt auf Ubuntu 18.04 – wie geht das?

  3. So sichern Sie Nginx mit Letsencrypt unter Ubuntu 20.04

  4. So richten Sie Let’s Encrypt (Certbot) unter Ubuntu 20.04 ein

  5. So sichern Sie Apache mit Lets Encrypt unter Ubuntu 18.04

So installieren Sie Nginx mit Let’s Encrypt TLS/SSL unter Ubuntu 20.04

So installieren Sie Let’s Encrypt SSL auf Ubuntu mit Apache

So installieren Sie Nginx mit Let’s Encrypt SSL unter Ubuntu 20.04 LTS

So installieren Sie Apache mit Let’s Encrypt SSL unter Ubuntu 20.04 LTS

So sichern Sie Nginx mit Let’s Encrypt unter Ubuntu 20.04

So sichern Sie Apache mit Let’s Encrypt unter Ubuntu 20.04