Secure Environment Variables Management System with GPG Encryption
- What is Central Var RXD?
- What Problems Does It Solve?
- Key Features
- Quick Installation
- Basic Usage Guide
- System Structure
- Technical Components
- Complete Example: Johnny's Story
- Integration in Your Project
- Complete Technical Documentation
Central Var RXD is a CLI (Command Line Interface) tool designed to manage environment variables in a secure and centralized way in software development projects. It uses GPG (GNU Privacy Guard) encryption to protect sensitive information such as passwords, API keys, tokens, and other credentials that should not be exposed in plain text.
- Problem: Environment variables contain sensitive information (passwords, API keys, tokens) that cannot be shared in plain text.
- Solution: Automatically encrypts all
.env
files using GPG with AES256 algorithm.
- Problem: Modern projects handle multiple environments (development, staging, production) with different configurations.
- Solution: Automatically manages separate files for each environment (
.env.dev.gpg
,.env.stg.gpg
,.env.prd.gpg
).
- π AES256 Encryption: Maximum security with GPG
- π Direct Execution: Variables only in memory, never on disk
- π― Multi-Environment: Development, staging, and production
- π₯ Secure Collaboration: Share projects without exposing credentials
- π‘οΈ Zero Temporary Files: No local traces
- π Authentication Required: Passphrase for each operation
# 1. Check dependencies
python3 --version # Python 3.6+
gpg --version # GPG 2.0+
# 2. Install Central Var RXD
# (See complete documentation in docs/eng/installer.md)
# 3. Verify installation
rxd_cli hello
π Complete Installation: docs/eng/installer.md
# Copy makefile to your project
cp ~/.rxd/makefile your-project/
cd your-project/
# Configure organization
sed -i 's/ORGANIZATION := jalo/ORGANIZATION := your-org/' makefile
mkdir -p .envs/
cat > .envs/.env.template << EOF
ENVIRONMENT=development
DATABASE_URL=
API_KEY=
SECRET_TOKEN=
EOF
# Create variables file
echo "DATABASE_URL=postgresql://localhost/myapp" > .env.dev
echo "API_KEY=dev-key-123" >> .env.dev
# Encrypt file
make encrypt file=.env.dev
# Remove original
rm .env.dev
make run-secure
~/.rxd/ # Base directory of the system
βββ cli.py # π§ SOURCE CODE of the CLI
βββ [ORGANIZACIONES]/ # Folders by organization/project
βββ jalo/ # Example: organization "jalo"
β βββ .envs/
β βββ .env.dev.gpg # Development variables (ENCRYPTED)
β βββ .env.stg.gpg # Staging variables (ENCRYPTED)
β βββ .env.prd.gpg # Production variables (ENCRYPTED)
βββ mi-empresa/ # Example: organization "mi-empresa"
β βββ .envs/
β βββ .env.dev.gpg
β βββ .env.stg.gpg
β βββ .env.prd.gpg
βββ otro-proyecto/
βββ .envs/
βββ .env.dev.gpg
βββ .env.stg.gpg
βββ .env.prd.gpg
Tu-Proyecto/ # Any of your projects
βββ makefile # π COPY - Only change ORGANIZATION
βββ src/
β βββ main.py # Your application that uses variables
βββ .envs/
βββ .env.template # π― CONFIGURATION - Define what you need
- Location:
~/.rxd/cli.py
- Function: Source code of the CLI that handles encryption/decryption
- Installed once and serves for all projects
- Copied: To the root of each project
- Configuration: Only change
ORGANIZATION := tu-proyecto
- Function: Simplifies execution with commands like
make run-secure
-
Location: In each individual project
-
Function: Define what variables that project specifically needs
-
Controls: Default environment and variables to inject
The
.env.template
is the configuration file that tells the CLI:- What default environment to use?
- What variables to inject in your code?
# .envs/.env.template ENVIRONMENT= # β Cannot be empty
development
β Use.env.dev.gpg
staging
β Use.env.stg.gpg
production
β Use.env.prd.gpg
Original Files (before encryption):
.env.dev # β File for DEVELOPMENT .env.prd # β File for PRODUCTION .env.stg # β File for STAGING
Encrypted Files (after encryption):
.env.dev.gpg # β Generated automatically .env.prd.gpg # β Generated automatically .env.stg.gpg # β Generated automatically
What if I use other names? β WILL NOT WORK - The system looks for exactly these names.
- Single Installation: Install the CLI in
~/.rxd/cli.py
(once) - By Project: Copy
makefile
and create.env.template
- Encryption: Variables are encrypted in
~/.rxd/[ORGANIZATION]/.envs/
- Execution:
make run-secure
decrypts, injects, and executes - Cleanup: Temporary files are automatically removed
Johnny has a project called "love_history" with the structure:
love_history/
βββ src/
βββ main.py # Uses AMOR_AGOSTO and AMOR_DICIEMBRE variables
His main.py
contains code that uses sensitive variables:
import os
amor_agosto = os.environ.get("AMOR_AGOSTO")
amor_diciembre = os.environ.get("AMOR_DICIEMBRE")
print(f"In August: {amor_agosto}")
print(f"In December: {amor_diciembre}")
- Has sensitive variables (person names π )
- Doesn't want those names to be in plain text on his computer because it's very confidential information
# Johnny installs the CLI once
# (following docs/eng/installer.md)
rxd_cli hello # β
Verify installation
cd love_history/
# Copy the system's makefile
cp ~/.rxd/makefile .
# Edit ONLY the organization
nano makefile
# Change: ORGANIZATION := jalo
# To: ORGANIZATION := love_history
mkdir -p .envs/
# Create file with actual values
cat > .env.prd << EOF
AMOR_AGOSTO=Fran
AMOR_DICIEMBRE=Diego
EOF
# Encrypt the file (here's the magic!)
make encrypt file=.env.prd
# This creates: ~/.rxd/love_history/.envs/.env.prd.gpg
# Remove the original file (for security)
# Β‘So no one fisguees on his computer his love life! π
rm .env.prd
Β‘Now comes the important part! Johnny needs to create the file that tells the system:
- What environment to use? (development, staging, production)
- What variables to inject? (only the ones he really needs)
cat > .envs/.env.template << EOF
ENVIRONMENT=production
AMOR_AGOSTO=
AMOR_DICIEMBRE=
EOF
What does each line do?
ENVIRONMENT=production
β "Hey system, by default use my.env.prd.gpg
"AMOR_AGOSTO=
β "I need this variable in my code" (value comes from encrypted file)AMOR_DICIEMBRE=
β "I also need this other variable"
π‘ Johnny's Tip: The template is like a "shopping list" - only ask for what you really need.
Now Johnny can run his project without anyone seeing his love secrets:
# Β‘One command and done!
make run-secure
Β‘It's like a spy movie! π΅οΈββοΈ
-
π Reading the Template:
- System: "Let's see... read
.envs/.env.template
" - System: "Ah! Johnny wants
ENVIRONMENT=production
,AMOR_AGOSTO
andAMOR_DICIEMBRE
"
- System: "Let's see... read
-
π Searching for the Treasure:
- System: "Since Johnny said production, I look for
~/.rxd/love_history/.envs/.env.prd.gpg
" - System: "Found! π"
- System: "Since Johnny said production, I look for
-
π Secure Decryption (Β‘GPG asks for the passphrase!):
- System: "GPG, decrypt this please..."
- GPG: "What's your passphrase, Johnny?" π
- Johnny: enters his passphrase
- GPG: "Done boss, here are your variables"
-
π Direct Injection (Β‘No temporary files!):
- System: "Capturing variables:
AMOR_AGOSTO=Fran AMOR_DICIEMBRE=Diego
" - System: "Injecting directly into the execution environment..."
- System: "Done! Variables are in memory, not in files"
- System: "Capturing variables:
-
π Project Execution:
- System: "Run!
python3 src/main.py
" - Johnny's code: "Great! I have my secret variables"
- System: "Run!
-
π§Ή Automatic Cleanup (Β‘No traces!):
- System: "Process finished, freeing memory..."
- System: "Variables removed from environment!"
π Super Cool: Variables NEVER go to local files! They only exist in memory during execution. π‘οΈ
# 1. Capture variables directly from CLI
exported_vars=$$(rxd_cli process $(PROJECT_PATH) $(ORGANIZATION))
# 2. Inject them into the current environment (Β‘no files!)
for var in $$exported_vars; do export $$var; done
# 3. Execute the program with those variables already available
bash -c "set -o allexport; python3 src/main.py"
π‘οΈ Super James Bond Security:
- β GPG asks for passphrase to decrypt
- β Variables only in memory, never on disk
- β Automatically removed after process ends
- β Zero temporary files in your project
love_history/ # Johnny's project
βββ makefile # ORGANIZATION := love_history
βββ src/
β βββ main.py # Uses variables
βββ .envs/
βββ .env.template # Defines what variables it needs
~/.rxd/ # Central system
βββ cli.py # CLI code
βββ love_history/ # Johnny's organization
βββ .envs/
βββ .env.prd.gpg # Securely encrypted variables
- π Extreme Security: AES256 encryption + passphrase + variables only in memory. Even the NSA wouldn't know about Fran and Diego!
- π Super Simplicity: One single
make run-secure
, enter your passphrase and Β‘done! - π₯ No Shame Collaboration: Can upload project to GitHub without coworkers seeing his crushes
- π Multi-Environment: Can create
.env.dev.gpg
for "test loves" π - π― Total Control: Only variables from template are injected - no "surprise" variables
- πΎ Zero Local Files: Variables NEVER touch Johnny's computer disk
- π Authentication Required: GPG always asks for his personal passphrase
π Johnny can sleep peacefully knowing his secrets are safe π΄
# Copy the makefile to your project
cp makefile tu-nuevo-proyecto/
cd tu-nuevo-proyecto/
# Edit the organization
sed -i 's/ORGANIZATION := jalo/ORGANIZATION := tu-organizacion/' makefile
# Create the structure
mkdir -p .envs/
# Define your required variables
cat > .envs/.env.template << EOF
ENVIRONMENT=development
DATABASE_URL=
API_KEY=
SECRET_TOKEN=
EOF
β οΈ IMPORTANT: Files MUST have specific names to work:
.env.dev
β For development (generates.env.dev.gpg
).env.prd
β For production (generates.env.prd.gpg
).env.stg
β For staging (generates.env.stg.gpg
)
# Create .env files for each environment (EXACT NAMES)
echo "DATABASE_URL=postgresql://localhost/myapp_dev" > .env.dev
echo "API_KEY=dev-api-key-123" >> .env.dev
echo "SECRET_TOKEN=dev-secret-123" >> .env.dev
echo "DATABASE_URL=postgresql://prod-server/myapp" > .env.prd
echo "API_KEY=prod-api-key-xyz" >> .env.prd
echo "SECRET_TOKEN=prod-secret-xyz" >> .env.prd
# Encrypt for each environment
make encrypt file=.env.dev # β Generates ~/.rxd/tu-org/.envs/.env.dev.gpg
make encrypt file=.env.prd # β Generates ~/.rxd/tu-org/.envs/.env.prd.gpg
# Remove original files for security
rm .env.dev .env.prd
# Run with automatically injected variables
make run-secure
# Or for specific environment
ENVIRONMENT=production make run-secure
Β‘Your project is integrated! π
Correct implementation of Central Var RXD requires complete reading of specific documentation. Each document contains critical technical information for system operation.
1. Installation and Configuration - CRITICAL
Critical Importance:
- Incorrect dependency installation prevents system operation
RXD_LOCAL_ENV_PATH
configuration is crucial for file localizationPATH
configuration is necessary forrxd_cli
execution
Document Content:
- Dependency installation: Python3, Click, GPG
- Environment variable configuration:
RXD_LOCAL_ENV_PATH
- Binary configuration for terminal execution
- Installation verification procedures
2. CLI Usage - CRITICAL
Critical Importance:
- Unfamiliar CLI commands prevent system use
- Incorrect syntax of parameters generates execution errors
- Understanding CLI command structure is essential for correct encryption
Document Content:
- 5 fundamental commands:
encrypt
,decrypt
,process
,hello
,init
- Specific syntax: mandatory and optional parameters
- Example implementations for each command
- Critical parameters:
--organization
, paths, file names
3. Makefile Usage - CRITICAL
Critical Importance:
- Understanding Makefile variables is necessary for customization
- Command knowledge is essential for project execution
- Correct configuration prevents organization errors
Document Content:
- 4 critical variables:
PROJECT_PATH
,ORGANIZATION
,GENERATE_FILE
,RXD_DEBUG
- 3 main commands:
run-secure
,encrypt
,decrypt
- Complete configuration with functional examples
- Specific syntax for each command
- Read each document completely, line by line
- Execute all example commands provided
- Verify each step's functionality before continuing
- Document important parameters for reference
- Test commands in a secure development environment
Complete reading and understanding these three documents guarantees 99% success in Central Var RXD implementation. Omission of this documentation results in equivalent probability of technical issues.
By omitting Installation and Configuration:
- "Command not found" errors
- "Environment variable not defined" errors
- Unable to localize encrypted files
- Significant time spent resolving issues
By omitting CLI Usage:
- Encrypting files in incorrect locations
- Unable to decrypt own files
- Incorrect organization use
- Execution errors with confusing messages
By omitting Makefile Usage:
- Incorrect organization configuration
make
command failures- Unable to execute projects securely
- Incorrect debug variable configuration
Central Var RXD - Secure and efficient environment variable management for development teams