GNU/Linux >> LINUX-Kenntnisse >  >> Cent OS

Installieren Sie EasyRSA (Certificate Authority)-CA auf CentOS / RHEL 8

Einführung

Easy-RSA-Übersicht

Easy-RSA ist ein Dienstprogramm zum Verwalten einer PKI-CA (Certificate Authority) zusätzlich zu X.509 PKI oder Public Key Infrastructure. Eine PKI basiert auf dem Konzept, einer bestimmten Autorität zu vertrauen, um einen entfernten Peer zu authentifizieren; Weitere Hintergrundinformationen zur Funktionsweise von PKI finden Sie unter Intro-To-PKI Dokument.

Der Code wurde in einer plattformneutralen POSIX-Shell geschrieben, die die Verwendung auf einer Vielzahl von Hostsystemen ermöglicht. Die offizielle Windows-Version wird auch mit den Programmen geliefert, die für die Verwendung von Easy-RSA erforderlich sind. Der Shell-Code versucht, die Anzahl externer Programme zu begrenzen, von denen er abhängt. Krypto-bezogene Aufgaben verwenden openssl als funktionales Backend.

Feature-Highlights

Hier ist eine nicht erschöpfende Liste der bemerkenswerteren Easy-RSA-Funktionen:

  • Easy-RSA kann mehrere PKIs verwalten, jede mit ihrer eigenen unabhängigen Konfiguration, ihrem eigenen Speicherverzeichnis und ihrer eigenen Handhabung von X.509-Erweiterungen.
  • Formatierungsoptionen für mehrere Antragstellernamen (X.509-DN-Feld) werden unterstützt. Für VPNs bedeutet dies, dass eine sauberere CommonName-Only-Konfiguration verwendet werden kann.
  • Ein einziges Backend wird für alle unterstützten Plattformen verwendet, um sicherzustellen, dass keine Plattform von den umfangreichen Funktionen „ausgelassen“ wird. Unix-Äquivalente (BSD, Linux usw.) und Windows werden alle unterstützt.
  • Die X.509-Unterstützung von Easy-RSA umfasst CRL, CDP, keyUsage/eKu-Attribute und zusätzliche Funktionen. Die enthaltene Unterstützung kann_als erweitertes Feature geändert oder erweitert werden.
  • Interaktive und automatisierte (Batch-)Betriebsarten
  • Flexible Konfiguration:Funktionen können über Befehlszeilenoptionen, Umgebungsvariablen, eine Konfigurationsdatei oder eine Kombination davon aktiviert werden.
  • Integrierte Standardeinstellungen ermöglichen die Verwendung von Easy-RSA ohne vorherige Bearbeitung einer Konfigurationsdatei.

EasyRSA ist also ein kostenloses und Open-Source-CLI-Dienstprogramm zum Erstellen einer Stammzertifizierungsstelle , sowie Zertifikate anfordern und signieren, einschließlich zwischengeschalteter Zertifizierungsstellen und Zertifikatsperrlisten (CRL).

Pakete in CentOS / RHEL aktualisieren

Aktualisieren Sie Softwarepakete in Ihrer Linux-Distribution, bevor Sie neue Software darauf installieren.

Führen Sie daher dnf aus Befehl zum Aktualisieren von Softwarepaketen in Ihrem CentOS / Red Hat Enterprise Linux.

# dnf update -y

Überprüfen Sie die in dieser Installationsanleitung verwendete Kernel-Version.

[root@rhel-pc ~]# uname -r
4.18.0-305.12.1.el8_4.x86_64
[root@rhel-pc ~]# 

Überprüfen Sie auch die Version der Linux-Distribution .

[root@rhel-pc ~]# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.4 (Ootpa)
[root@rhel-pc ~]# 

Installieren Sie EasyRSA auf CentOS / RHEL

Laden Sie die neueste Version von EasyRSA herunter mit dem wget-Befehl.

[root@rhel-pc mnt]# cd /mnt
[root@rhel-pc mnt]#  wget https://github.com/OpenVPN/easy-rsa/releases/download/v3.0.8/EasyRSA-3.0.8.tgz
--2021-08-15 23:10:26--  https://github.com/OpenVPN/easy-rsa/releases/download/v3.0.8/EasyRSA-3.0.8.tgz
Resolving github.com (github.com)... 140.82.121.3
Connecting to github.com (github.com)|140.82.121.3|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-releases.githubusercontent.com/4519663/2e0dee80-f7f3-11ea-9ba4-dc973db12175?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210815%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210815T210829Z&X-Amz-Expires=300&X-Amz-Signature=5199380d851889a82d52ae4950917b20c7717e387f0c6b62054969f554de8e04&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=4519663&response-content-disposition=attachment%3B%20filename%3DEasyRSA-3.0.8.tgz&response-content-type=application%2Foctet-stream [following]
--2021-08-15 23:10:28--  https://github-releases.githubusercontent.com/4519663/2e0dee80-f7f3-11ea-9ba4-dc973db12175?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210815%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210815T210829Z&X-Amz-Expires=300&X-Amz-Signature=5199380d851889a82d52ae4950917b20c7717e387f0c6b62054969f554de8e04&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=4519663&response-content-disposition=attachment%3B%20filename%3DEasyRSA-3.0.8.tgz&response-content-type=application%2Foctet-stream
Resolving github-releases.githubusercontent.com (github-releases.githubusercontent.com)... 185.199.111.154, 185.199.108.154, 185.199.109.154, ...
Connecting to github-releases.githubusercontent.com (github-releases.githubusercontent.com)|185.199.111.154|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 48907 (48K) [application/octet-stream]
Saving to: ‘EasyRSA-3.0.8.tgz’

EasyRSA-3.0.8.tgz                     100%[=======================================================================>]  47.76K  --.-KB/s    in 0.1s    

2021-08-15 23:10:29 (414 KB/s) - ‘EasyRSA-3.0.8.tgz’ saved [48907/48907]

[root@rhel-pc mnt]# 

Extrahieren Sie die heruntergeladene tar-Datei, indem Sie tar ausführen Befehl.

[root@rhel-pc mnt]# tar xfv EasyRSA-3.0.8.tgz 
EasyRSA-3.0.8/
EasyRSA-3.0.8/easyrsa
EasyRSA-3.0.8/openssl-easyrsa.cnf
EasyRSA-3.0.8/vars.example
EasyRSA-3.0.8/x509-types/
EasyRSA-3.0.8/gpl-2.0.txt
EasyRSA-3.0.8/mktemp.txt
EasyRSA-3.0.8/COPYING.md
EasyRSA-3.0.8/ChangeLog
EasyRSA-3.0.8/README.md
EasyRSA-3.0.8/README.quickstart.md
EasyRSA-3.0.8/doc/
EasyRSA-3.0.8/doc/EasyRSA-Advanced.md
EasyRSA-3.0.8/doc/EasyRSA-Readme.md
EasyRSA-3.0.8/doc/EasyRSA-Upgrade-Notes.md
EasyRSA-3.0.8/doc/Hacking.md
EasyRSA-3.0.8/doc/Intro-To-PKI.md
EasyRSA-3.0.8/x509-types/COMMON
EasyRSA-3.0.8/x509-types/ca
EasyRSA-3.0.8/x509-types/client
EasyRSA-3.0.8/x509-types/code-signing
EasyRSA-3.0.8/x509-types/email
EasyRSA-3.0.8/x509-types/kdc
EasyRSA-3.0.8/x509-types/server
EasyRSA-3.0.8/x509-types/serverClient
[root@rhel-pc mnt]# 

Benennen Sie dann das extrahierte Verzeichnis um.

[root@rhel-pc mnt]# mv EasyRSA-3.0.8 EasyRSA

PKI- und CA-Zertifikat generieren

Sie können dies mit diesem Befehl unten tun:

[root@rhel-pc mnt]# cd EasyRSA/
[root@rhel-pc EasyRSA]# ./easyrsa init-pki

init-pki complete; you may now create a CA or requests.
Your newly created PKI dir is: /mnt/EasyRSA/pki


[root@rhel-pc EasyRSA]# 

Generieren Sie nun Ihre Zertifizierungsstelle (CA) , die zum Signieren von Server- und Client-Zertifikatsignierungsanforderungen (CSR) mit dem folgenden Befehl verwendet wird.

[root@rhel-pc EasyRSA]# ./easyrsa build-ca
Using SSL: openssl OpenSSL 1.1.1g FIPS  21 Apr 2020

Enter New CA Key Passphrase: 
Re-Enter New CA Key Passphrase: 
Generating RSA private key, 2048 bit long modulus (2 primes)
..................+++++
...........................................................................................................................................................+++++
e is 65537 (0x010001)
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Common Name (eg: your user, host, or server name) [Easy-RSA CA]:unixcop

CA creation complete and you may now import and sign cert requests.
Your new CA certificate file for publishing is at:
/mnt/EasyRSA/pki/ca.crt


[root@rhel-pc EasyRSA]# 

Server-SSL-Zertifikat generieren

Also generieren wir einen privaten RSA-Schlüssel und eine CSR mit dem folgenden Befehl.

[root@rhel-pc EasyRSA]# ./easyrsa gen-req easyrsa.unixcop.com nopass
Using SSL: openssl OpenSSL 1.1.1g FIPS  21 Apr 2020
Generating a RSA private key
............................................................................................................................................................................................+++++
..........+++++
writing new private key to 'https://1118798822.rsc.cdn77.org/mnt/EasyRSA/pki/easy-rsa-6230.db5Ie8/tmp.5R7sqs'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Common Name (eg: your user, host, or server name) [easyrsa.unixcop.com]:

Keypair and certificate request completed. Your files are:
req: /mnt/EasyRSA/pki/reqs/easyrsa.unixcop.com.req
key: /mnt/EasyRSA/pki/private/easyrsa.unixcop.com.key


[root@rhel-pc EasyRSA]# 

Signieren Sie außerdem Ihre Server-CSR mit dem privaten Schlüssel der Zertifizierungsstelle (CA).

[root@rhel-pc EasyRSA]# ./easyrsa sign-req server easyrsa.unixcop.com
Using SSL: openssl OpenSSL 1.1.1g FIPS  21 Apr 2020


You are about to sign the following certificate.
Please check over the details shown below for accuracy. Note that this request
has not been cryptographically verified. Please be sure it came from a trusted
source or that you have verified the request checksum with the sender.

Request subject, to be signed as a server certificate for 825 days:

subject=
    commonName                = easyrsa.unixcop.com


Type the word 'yes' to continue, or any other input to abort.
  Confirm request details: yes
Using configuration from /mnt/EasyRSA/pki/easy-rsa-6260.UVEjyC/tmp.nTGkfr
Enter pass phrase for /mnt/EasyRSA/pki/private/ca.key:
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName            :ASN.1 12:'easyrsa.unixcop.com'
Certificate is to be certified until Nov 18 21:18:53 2023 GMT (825 days)

Write out database with 1 new entries
Data Base Updated

Certificate created at: /mnt/EasyRSA/pki/issued/easyrsa.unixcop.com.crt


[root@rhel-pc EasyRSA]# 

Sie haben das SSL-Zertifikat erfolgreich signiert.

Um zu überprüfen, ob Ihr SSL-Zertifikat korrekt generiert wurde, können Sie auch openssl ausführen Befehl wie unten gezeigt.

[root@rhel-pc EasyRSA]#  openssl verify -CAfile pki/ca.crt /mnt/EasyRSA/pki/issued/easyrsa.unixcop.com.crt
/mnt/EasyRSA/pki/issued/easyrsa.unixcop.com.crt: OK
[root@rhel-pc EasyRSA]# 

Generiere (Diffie Hellman)-Schlüssel

Wir werden also ein Diffie erzeugen Hellmann Schlüssel, der vom Schlüsselaustauschprozess verwendet werden soll. Verwenden Sie den folgenden Befehl, um ihn zu generieren.

[root@rhel-pc EasyRSA]# ./easyrsa gen-dh
Using SSL: openssl OpenSSL 1.1.1g FIPS  21 Apr 2020
Generating DH parameters, 2048 bit long safe prime, generator 2
This is going to take a long time
......................................................................................................................................................................................................................................................................................................................................+..+...........................................+.....................+..........................................................................................+..........................................................................................................................................................................................................................................................................................................................................................................+........................................+....................................................................................................................+............................................................................................................................................................................................................+...................................+........................................................................................................................................................................................................................................................................+...........+......................................................................................................+...........................................................+..........................+...............................................................................................................................................+..................................................++*++*++*++*

DH parameters of size 2048 created at /mnt/EasyRSA/pki/dh.pem


[root@rhel-pc EasyRSA]# 

Generieren Sie ein Client-SSL-Zertifikat

Generieren Sie ein SSL-Zertifikat für Ihren Client.

Wie im Beispiel gezeigt, ist der Client qadry.unixcop.com

[root@rhel-pc EasyRSA]#  ./easyrsa gen-req qadry.unixcop.com nopass
Using SSL: openssl OpenSSL 1.1.1g FIPS  21 Apr 2020
Generating a RSA private key
..+++++
.............................+++++
writing new private key to 'https://1118798822.rsc.cdn77.org/mnt/EasyRSA/pki/easy-rsa-6458.r26VDM/tmp.fjd968'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Common Name (eg: your user, host, or server name) [qadry.unixcop.com]:

Keypair and certificate request completed. Your files are:
req: /mnt/EasyRSA/pki/reqs/qadry.unixcop.com.req
key: /mnt/EasyRSA/pki/private/qadry.unixcop.com.key


[root@rhel-pc EasyRSA]# 

Sie können das Client-SSL-Zertifikat auch wie unten gezeigt signieren.

[root@rhel-pc EasyRSA]# ./easyrsa sign-req client qadry.unixcop.com
Using SSL: openssl OpenSSL 1.1.1g FIPS  21 Apr 2020


You are about to sign the following certificate.
Please check over the details shown below for accuracy. Note that this request
has not been cryptographically verified. Please be sure it came from a trusted
source or that you have verified the request checksum with the sender.

Request subject, to be signed as a client certificate for 825 days:

subject=
    commonName                = qadry.unixcop.com


Type the word 'yes' to continue, or any other input to abort.
  Confirm request details: yes
Using configuration from /mnt/EasyRSA/pki/easy-rsa-6507.0eJrdy/tmp.sFYefJ
Enter pass phrase for /mnt/EasyRSA/pki/private/ca.key:
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
commonName            :ASN.1 12:'qadry.unixcop.com'
Certificate is to be certified until Nov 18 21:29:23 2023 GMT (825 days)

Write out database with 1 new entries
Data Base Updated

Certificate created at: /mnt/EasyRSA/pki/issued/qadry.unixcop.com.crt


[root@rhel-pc EasyRSA]# 

Sie haben also das Client-SSL-Zertifikat erfolgreich generiert und signiert.

Kopieren Sie auch Ihr Zertifikat der Zertifizierungsstelle (CA) in /etc/pki/ca-trust/source/anchors/ Ihrer Linux-Clients, Ihre Zertifizierungsstelle zu ihrer Liste vertrauenswürdiger Zertifizierungsstellen hinzuzufügen.

Schlussfolgerung

Wir haben also EasyRSA erfolgreich auf CentOS / Red Hat Enterprise Linux 8 installiert. Wir haben auch eine Zertifizierungsstelle und signierte SSL-Zertifikate von Server und Client mithilfe von easyrsa konfiguriert Befehl.


Cent OS
  1. So installieren Sie SSL auf RHEL 8 / CentOS 8

  2. So installieren Sie phpMyAdmin auf RHEL 8 / CentOS 8

  3. So installieren Sie P7Zip auf RHEL 8 / CentOS 8

  4. So installieren Sie ntfs-3g auf RHEL 8 / CentOS 8

  5. Installieren Sie Webmin auf CentOS 7 / RHEL 7

Installieren Sie nmap auf RHEL 8 / CentOS 8

So installieren Sie mongodb auf RHEL 8 / CentOS 8

So installieren Sie Maven auf RHEL 8 / CentOS 8

So installieren Sie cpan auf RHEL 8 / CentOS 8

Installieren Sie Python 2 auf RHEL 8 / CentOS 8

Erstellen Sie Ihre eigene Zertifizierungsstelle (CA) in CentOS/RHEL