Securing a Replica Set (KeyFile)
Step-by-step guide to securing a MongoDB replica set using Keyfiles.
Generate a keyfile
openssl rand -base64 756 > keyfile
chmod 400 keyfileuse admin
db.createUser({user:"dmk", pwd:passwordPrompt(), roles:[{role:"root", db:"admin"}]})mongodb@vm00:/home/mongodb/ [mdbrs01] ms
test> use admin
switched to db admin
admin> db.createUser({user:"dmk", pwd:passwordPrompt(), roles:[{role:"root", db:"admin"}]})
Enter password
{ ok: 1 }Stop all nodes, starting with SECONDARY nodes
SECONDARY nodesUpdate MongoDB configuration files
Restart all nodes
Last updated