# Encryption and Compression

This section guides you through configuring encryption and compression for S3-compatible storage using the MinIO Client (`mc`).&#x20;

{% embed url="<https://drive.google.com/file/d/1eUlgh_YQorIYBadUrNHDuvt2AG8gA_sf/view?usp=sharing>" %}
Encryption and Compression
{% endembed %}

Encryption ensures data security, while compression optimizes storage usage.

### Step 1: Install MinIO Client

The MinIO Client allows you to interact with your MinIO server. The MinIO Server provides an S3-compatible API and supports core S3 features.&#x20;

The MinIO Server provides an S3-compatible API and supports core S3 features. Choose one of the following installation methods for Linux:

**RPM (RHEL-based Systems)**

* Download the latest stable MinIO RPM package. Install the package using `dnf`:

```bash
wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio-20241218131544.0.0-1.x86_64.rpm -O minio.rpm
sudo dnf install minio.rpm
```

**DEB (Debian/Ubuntu Systems)**

* Download the appropriate `.deb` package from the MinIO Downloads Page. Install the package using `dpkg`:

```bash
wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio_20241218131544.0.0_amd64.deb -O minio.deb
sudo dpkg -i minio.deb
```

**Binary Installation (Universal Method)**

* Download the MinIO Server binary. Make the binary executable and move the binary to a directory in your system PATH:

```bash
wget https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x minio
sudo mv minio /usr/local/bin/
```

#### Installing MinIO Client (mc)

The MinIO Client allows command-line interaction with your MinIO server.

1. Download the MinIO Client binary:

   ```bash
   wget https://dl.min.io/client/mc/release/linux-amd64/mc
   ```
2. Make the binary executable:

   ```bash
   chmod +x mc
   ```
3. Move the binary to a directory in your system PATH:

   ```bash
   sudo mv mc /usr/local/bin/mc
   ```
4. Verify the installation:

   ```bash
   mc --version
   ```

For other operating systems, refer to this [resource](https://min.io/docs/minio/linux/index.html).

### Step 2: Set Up mc Alias

1. Set an alias for your server:

   ```bash
   mc alias set zcn https://<BLIMP_DOMAIN> <ACCESS_KEY> <SECRET_KEY> --api S3v2
   ```

   * Replace `<BLIMP_DOMAIN>` with the domain link from the Blimp output.
   * Replace `<ACCESS_KEY>` and `<SECRET_KEY>` with your credentials.

   Example:

   ```bash
   mc alias set zcn https://blimpibh5l.zus.network shahnawaz rootroot --api S3v2
   ```
2. Verify the alias setup by listing buckets:

   ```bash
   mc ls zcn
   ```

### Step 3: Create a Bucket

1. Create a bucket for storing encrypted and compressed data:

   ```bash
   mc mb zcn/encryption-compression
   ```
2. Confirm the bucket creation by listing the contents:

   ```bash
   mc ls zcn
   ```

### Step 4: Upload Files with Compression

1. Copy files or directories recursively to the bucket, applying compression:

   ```bash
   mc cp --recursive ../mc/docs zcn/encryption-compression/
   ```

   Example commands:

   ```bash
   mc cp --recursive ../mc/docs zcn/encryption-compression/
   mc cp --recursive ../mc/buildscripts zcn/encryption-compression/
   mc cp --recursive ../mc/primary zcn/encryption-compression/
   ```
2. List the contents of the bucket to verify the upload:

   ```bash
   mc ls zcn/encryption-compression/
   ```

### Step 5: Test Encryption

1. Ensure that the uploaded files are encrypted on the server by verifying through:

   ```bash
   mc stat zcn/encryption-compression/<FILE_NAME>
   ```

   * Replace `<FILE_NAME>` with the name of any uploaded file.
   * Check the metadata to confirm encryption.
2. To download and decrypt, use:

   ```bash
   mc cp zcn/encryption-compression/<FILE_NAME> /local/path/
   ```

### Notes

* **Recursive Upload**: Use the `--recursive` flag to upload entire directories.
* **Bucket Verification**: Always verify the presence of the bucket and its contents after each operation.
* **Compression**: Compression is applied automatically during file transfer. Ensure that the server supports compression for optimal results.
* **Encryption**: Encryption is configured at the server level. Confirm the settings in your ZS3Server configuration to enable encryption.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zus.network/zus-docs/system-overview/storage/zs3-server/encryption-and-compression.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
