Home Operation and Maintenance Linux Operation and Maintenance How to use OpenSSL command line on Debian

How to use OpenSSL command line on Debian

Apr 13, 2025 am 06:27 AM
tool ai

How to use OpenSSL command line on Debian

The OpenSSL command line tool under the Debian system is powerful and can be used for various tasks such as key pair generation, certificate creation and management, data encryption and decryption. This article will guide you to quickly get started with OpenSSL.

1. OpenSSL installation

First, make sure your Debian system has OpenSSL installed. If not installed, execute the following command:

 sudo apt update
sudo apt install openssl
Copy after login

2. Key pair generation

1. Generate RSA private key:

 openssl genrsa -out private.key 2048
Copy after login

This command generates a 2048-bit RSA private key and saves it to the private.key file.

2. Generate RSA public key:

 openssl rsa -in private.key -pubout -out public.key
Copy after login

This command extracts the public key from private.key and saves it to the public.key file.

3. Creation of self-signed certificates

 openssl req -new -x509 -days 365 -key private.key -out certificate.crt
Copy after login

This command creates a self-signed certificate with a validity period of 365 days and saves it to the certificate.crt file. During the execution process, the system will prompt you to enter information such as country, organization name, etc.

4. Data encryption and decryption

1. File encryption:

 openssl enc -aes-256-cbc -salt -in plaintext.txt -out encrypted.bin
Copy after login

This command uses the AES-256-CBC algorithm to encrypt the plaintext.txt file, and the encryption results are saved to the encrypted.bin file. You will be prompted for a password.

2. File decryption:

 openssl enc -d -aes-256-cbc -in encrypted.bin -out decrypted.txt
Copy after login

This command uses the same password to decrypt the encrypted.bin file, and save the decryption result to the decrypted.txt file.

5. Certificate information viewing and verification

1. View certificate information:

 openssl x509 -in certificate.crt -text -noout
Copy after login

This command displays certificate details, including subject, issuer, validity period, etc.

2. Verify the certificate signature:

 openssl verify -CAfile ca.crt certificate.crt
Copy after login

This command verifies whether certificate.crt is issued by ca.crt .

6. Certificate Signing Request (CSR) and PKCS#12 file generation and operation

1. Generate CSR:

 openssl req -new -key private.key -out certificate_signing_request.csr
Copy after login

This command generates a CSR file to apply for a certificate from the Certificate Authority (CA).

2. Generate PKCS#12 file:

 openssl pkcs12 -export -in certificate.crt -inkey private.key -out keystore.p12 -name mycert
Copy after login

This command packages the certificate and private key into a PKCS#12 file, alias mycert .

3. Extract certificate and private key from PKCS#12 file:

  • Extract certificates:

     openssl pkcs12 -in keystore.p12 -clcerts -nokeys -out certificate.crt
    Copy after login
  • Extract the private key:

     openssl pkcs12 -in keystore.p12 -nocerts -out private.key -nodes
    Copy after login

The above commands cover common functions of OpenSSL under Debian system. For more advanced features, please refer to the official OpenSSL documentation.

The above is the detailed content of How to use OpenSSL command line on Debian. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Centos shutdown command line Centos shutdown command line Apr 14, 2025 pm 09:12 PM

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

How to check CentOS HDFS configuration How to check CentOS HDFS configuration Apr 14, 2025 pm 07:21 PM

Complete Guide to Checking HDFS Configuration in CentOS Systems This article will guide you how to effectively check the configuration and running status of HDFS on CentOS systems. The following steps will help you fully understand the setup and operation of HDFS. Verify Hadoop environment variable: First, make sure the Hadoop environment variable is set correctly. In the terminal, execute the following command to verify that Hadoop is installed and configured correctly: hadoopversion Check HDFS configuration file: The core configuration file of HDFS is located in the /etc/hadoop/conf/ directory, where core-site.xml and hdfs-site.xml are crucial. use

How is the GPU support for PyTorch on CentOS How is the GPU support for PyTorch on CentOS Apr 14, 2025 pm 06:48 PM

Enable PyTorch GPU acceleration on CentOS system requires the installation of CUDA, cuDNN and GPU versions of PyTorch. The following steps will guide you through the process: CUDA and cuDNN installation determine CUDA version compatibility: Use the nvidia-smi command to view the CUDA version supported by your NVIDIA graphics card. For example, your MX450 graphics card may support CUDA11.1 or higher. Download and install CUDAToolkit: Visit the official website of NVIDIACUDAToolkit and download and install the corresponding version according to the highest CUDA version supported by your graphics card. Install cuDNN library:

Detailed explanation of docker principle Detailed explanation of docker principle Apr 14, 2025 pm 11:57 PM

Docker uses Linux kernel features to provide an efficient and isolated application running environment. Its working principle is as follows: 1. The mirror is used as a read-only template, which contains everything you need to run the application; 2. The Union File System (UnionFS) stacks multiple file systems, only storing the differences, saving space and speeding up; 3. The daemon manages the mirrors and containers, and the client uses them for interaction; 4. Namespaces and cgroups implement container isolation and resource limitations; 5. Multiple network modes support container interconnection. Only by understanding these core concepts can you better utilize Docker.

Centos8 restarts ssh Centos8 restarts ssh Apr 14, 2025 pm 09:00 PM

The command to restart the SSH service is: systemctl restart sshd. Detailed steps: 1. Access the terminal and connect to the server; 2. Enter the command: systemctl restart sshd; 3. Verify the service status: systemctl status sshd.

Centos install mysql Centos install mysql Apr 14, 2025 pm 08:09 PM

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.

How to monitor HDFS status on CentOS How to monitor HDFS status on CentOS Apr 14, 2025 pm 07:33 PM

There are many ways to monitor the status of HDFS (Hadoop Distributed File System) on CentOS systems. This article will introduce several commonly used methods to help you choose the most suitable solution. 1. Use Hadoop’s own WebUI, Hadoop’s own Web interface to provide cluster status monitoring function. Steps: Make sure the Hadoop cluster is up and running. Access the WebUI: Enter http://:50070 (Hadoop2.x) or http://:9870 (Hadoop3.x) in your browser. The default username and password are usually hdfs/hdfs. 2. Command line tool monitoring Hadoop provides a series of command line tools to facilitate monitoring

How to choose the PyTorch version on CentOS How to choose the PyTorch version on CentOS Apr 14, 2025 pm 06:51 PM

When installing PyTorch on CentOS system, you need to carefully select the appropriate version and consider the following key factors: 1. System environment compatibility: Operating system: It is recommended to use CentOS7 or higher. CUDA and cuDNN:PyTorch version and CUDA version are closely related. For example, PyTorch1.9.0 requires CUDA11.1, while PyTorch2.0.1 requires CUDA11.3. The cuDNN version must also match the CUDA version. Before selecting the PyTorch version, be sure to confirm that compatible CUDA and cuDNN versions have been installed. Python version: PyTorch official branch

See all articles