A secure system for managing sensitive configuration files for different environments.
This tool allows you to:
- Encrypt sensitive configuration files with a private key
- Upload the encrypted configurations to a server
- Securely retrieve and decrypt configurations when needed
This tool depends on:
openssl- For encryption/decryption (usually pre-installed)curl- For downloading configurations (usually pre-installed)base64- For encoding/decoding (usually pre-installed)jq- For JSON parsing (will be auto-installed if missing)
The script will automatically check for and install jq if it's not present.
Copy the example environment file to create your own:
cp .env.example .envEdit the .env file and set the following variables:
PRIVATE_KEY: A secure key used for encryptionSERVER_IP: The SSH connection string (user@hostname) for your serverSSH_KEY_PATH: Path to your SSH private key for authentication
To encrypt a configuration file and upload it to the server:
./update.sh stagingThis will:
- Read the
staging.configfile - Encrypt it using your private key
- Convert to base64 format
- Upload to your server at
/var/www/ops/staging.config
The script automatically detects which environment's configuration to update based on the command line argument, so you can easily update any environment:
./update.sh productionThe system uses two scripts for configuration management:
curl_install.sh- For downloading and running the installation remotelyinit_mi_config.sh- The main script for both initial setup and updates
To perform the initial configuration on a new server, use the init_mi_config.sh script:
sudo ./init_mi_config.sh staging "your_private_key"This will:
- Fetch the encrypted configuration from
https://admin-api.missioninbox.com/ops/staging.config - Decrypt it using the provided private key
- Store the decrypted configuration at
/opt/missioninbox/environment.config - Extract any
repo_private_keyfield and save it to/opt/missioninbox/repo.key - Install itself to
/usr/bin/init_mi_config.shfor future use - Store the environment and private key securely for automatic updates
For new developers who have received the private key, you can quickly set up your environment with a single command:
curl -sSL https://raw.githubusercontent.com/MissionInbox/ops-config-manager/refs/heads/master/curl_install.sh | sudo bash -s -- staging "your_private_key"Replace staging with the environment you need (production, etc.) and "your_private_key" with the actual private key you've received through secure channels.
This single command downloads and runs the installation script to perform the complete setup process.
Once the initial setup is complete, other repositories can refresh the configuration by simply running:
/usr/bin/init_mi_config.shThis script will automatically:
- Read the stored environment and private key
- Download the latest configuration
- Update
/opt/missioninbox/environment.configwith the latest values
No additional arguments are needed as the script uses the stored parameters from the initial setup.
Add this to the beginning of your scripts in other repositories:
#!/bin/bash
# Check if the configuration updater is available
if [ -x "/usr/bin/init_mi_config.sh" ]; then
echo "Refreshing configuration..."
/usr/bin/init_mi_config.sh
else
echo "Warning: Configuration updater not installed"
echo "Run the ops-config-manager setup first"
fi
# Continue with your script...Create environment-specific configuration files in the configs directory:
configs/staging.config- Configuration for staging environmentconfigs/production.config- Configuration for production environment
These files can contain any sensitive data that needs to be securely managed, including:
The configuration files support some special fields that receive special handling:
repo_private_key: A base64-encoded SSH private key that will be:- Extracted from the configuration file
- Decoded and saved to
/opt/missioninbox/repo.key - Given proper permissions (600) for use as an SSH key
- This allows secure storage of deployment keys for accessing repositories
- Never commit your
.envfile or your private keys to version control - Keep your private keys secure and limit access to authorized personnel
- Use strong, unique keys for each project
- Rotate keys periodically for enhanced security