Last active
August 24, 2020 20:52
-
-
Save kennwhite/1647b170bca829c1834ea28022328cdc to your computer and use it in GitHub Desktop.
Bootstrap mongodb binary (mongod) properly from command line with encrypted storage engine enabled (full database encryption)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See: https://docs.mongodb.com/manual/tutorial/configure-encryption/#local-key-management | |
# As non-root user, possibly in a startup script: | |
/usr/bin/mongod \ | |
--fork \ | |
--logpath=/tmp/mdb.log \ | |
--dbpath=/data/db \ | |
--enableEncryption \ | |
--encryptionKeyFile <( curl -s https://some.web.service/keys/mykey ) | |
# Alternatively, as root: | |
KEYTMP=/dev/shm/mbd/keys | |
mkdir -p $KEYTMP | |
curl -s https://some.web.service/keys/mykey > $KEYTMP/key1 | |
chmod 0600 $KEYDIR/key1 | |
chown mongodb.mongodb $KEYTMP/key1 | |
runuser -u mongodb -- /usr/bin/mongod \ | |
--fork \ | |
--logpath=/tmp/mdb.log \ | |
--dbpath=/data/db \ | |
--enableEncryption \ | |
--encryptionKeyFile $KEYTMP/key1 | |
# Remove the temporary key from non-persistent memory | |
echo > $KEYTMP/key1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment