MongoDB replica set with simple password authentication MongoDB replica set with simple password authentication mongodb mongodb

MongoDB replica set with simple password authentication


I finally found the answer. MongoDB replica set needs both user account and keyfile. Keyfile seems for authentication between servers in the replica set, not for logging in.

Create mongodb key file on linux, copy to all db servers with mode 600 intact:

cdopenssl rand -base64 741 > mongodb.keychmod 600 mongodb.key

mongod.conf file:

replication:  replSetName: rs0security:  authorization: enabled  keyFile: /home/USERNAME/mongodb.key

Admin user:

(just like in question content)