Home > Operation and Maintenance > Linux Operation and Maintenance > How to protect sensitive data in CentOS systems using encrypted storage and transmission

How to protect sensitive data in CentOS systems using encrypted storage and transmission

WBOY
Release: 2023-07-06 22:19:35
Original
1860 people have browsed it

How to use encrypted storage and transmission to protect sensitive data in CentOS systems

Introduction
In today's digital age, protecting sensitive data and privacy has become particularly important. In CentOS systems, we can use encrypted storage and transmission to effectively protect sensitive data. This article will introduce how to use encryption technology to protect sensitive data in CentOS systems and provide corresponding code examples.

Encrypted Storage
In CentOS systems, we can use LUKS (Linux Unified Key Setup) technology to encrypt the disk. Here are the steps to use LUKS to encrypt data in a CentOS system:

  1. Install the cryptsetup package:

    sudo yum install cryptsetup
    Copy after login
  2. Create a blank encryption device:

    sudo cryptsetup luksFormat /dev/sdb
    Copy after login

    This command will create an encrypted device on /dev/sdb.

  3. Open encrypted device:

    sudo cryptsetup luksOpen /dev/sdb encrypted_device
    Copy after login

    This will open the encrypted device and map it to encrypted_device.

  4. Format device:

    sudo mkfs.ext4 /dev/mapper/encrypted_device
    Copy after login

    This will create a file system on the encrypted device.

  5. Mount the device:

    sudo mkdir /mnt/encrypted
    sudo mount /dev/mapper/encrypted_device /mnt/encrypted
    Copy after login

    This will mount the device to the /mnt/encrypted directory.

You can now store sensitive data in the /mnt/encrypted directory. When the device is not mounted, data will be encrypted.

Encrypted transmission
In the CentOS system, we can use the OpenSSL library to implement encrypted transmission. Here are the steps to use the OpenSSL library to secure data transmission in CentOS systems:

  1. Install the OpenSSL library:

    sudo yum install openssl
    Copy after login
  2. Generate public and private keys :

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

    This will generate private and public keys named private.key and public.key.

  3. Encrypt data:

    openssl rsautl -encrypt -in input.txt -inkey public.key -pubin -out encrypted.txt
    Copy after login

    This will encrypt the input.txt file using the public key and save the result in the encrypted.txt file.

  4. Decrypt data:

    openssl rsautl -decrypt -in encrypted.txt -inkey private.key -out output.txt
    Copy after login

    This will decrypt the encrypted.txt file using the private key and save the result in the output.txt file.

Now you can use encrypted.txt files for secure data transfer. Only the person with the private key can decrypt the data.

Conclusion
Protecting sensitive data in CentOS systems is crucial to protecting personal privacy and confidential information. By using LUKS technology for encrypted storage and the OpenSSL library for encrypted transmission, we can effectively protect sensitive data in CentOS systems. Hope this article helps you!

The above is the detailed content of How to protect sensitive data in CentOS systems using encrypted storage and transmission. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template