MongoDB authentication is disabled¶
The mongodb_auth check warns if authentication is disabled on a MongoDB instance.
Description¶
Without authentication, any client that can reach the instance over the network can connect to it, read and change data, and run administrative commands.
The check reads the startup options of the instance with the getCmdLineOpts command. It considers authentication enabled if one of these options is set:
security.authorizationset toenabledsecurity.keyFilesecurity.clusterAuthMode
The last two options enable internal authentication between the members of a replica set or a sharded cluster, which also enforces access control for clients. If none of these options is set, the check returns a warning.
Resolution¶
To enable access control on a standalone instance:
- Connect to the instance with
mongoshand create a user administrator in theadmindatabase, if you don’t have one yet. -
Edit the
mongod.conffile and turn on authorization:security: authorization: enabled -
Restart
mongodto apply the change. - Connect as the user administrator and create users with the roles that your applications need.
To set up users and roles in more detail, follow the MongoDB guide to enable access control on a self-managed deployment.
For a replica set or a sharded cluster, enable internal authentication with a keyfile or X.509 certificates instead. To avoid downtime, enforce keyfile access control on the running replica set.
Need more support from Percona?¶
Percona experts bring years of experience in tackling tough database performance issues and design challenges.