MongoDB supports the following authentication mechanisms depending on your MongoDB version:
MongoDB Version | Default Authentication Mechanism |
|---|---|
4.0 or later | |
3.0 to 3.6 | SCRAM authentication mechanism with``SHA-1`` hash function. |
2.6 or earlier | MongoDB Challenge and Response ( |
The MongoDB Agent can use SCRAM-SHA-1 or SCRAM-SHA-256 to authenticate to hosts that enforce access control.
Note
With Automation, Cloud Manager manages MongoDB Agent authentication for you. To learn more about authentication, see Set up Username and Password Authentication for a Project.
Prerequisites
Configure Deployments to Use Authentication
The MongoDB Agent interacts with the MongoDB databases in your deployment as a MongoDB user would. As a result, you must configure your MongoDB deployment and the MongoDB Agent to support authentication.
You can specify the deployment's authentication mechanisms when adding the deployment, or you can edit the settings for an existing deployment. At minimum, the deployment must enable the authentication mechanism you want the MongoDB Agent to use. The MongoDB Agent can use any supported authentication mechanism.
Configure Deployment Authentication
Select your deployment type to view the appropriate steps.
Configure Deployments Managed by Automation
When you install the MongoDB Agent with Automation, Cloud Manager creates a user to authenticate on the MongoDB database. Cloud Manager create this MongoDB user (mms-automation) in the admin database with the correct privileges for each MongoDB Agent function.
Configure these credentials in Cloud Manager.
In MongoDB Cloud Manager, go to the Security page for your project.
If it's not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.
If it's not already displayed, select your desired project from the Projects menu in the navigation bar.
In the sidebar, click Security under the Database heading.
The Security page displays.
Click Settings.
Continue through the modal until you see the Configure Cloud Manager Agents page.
Add the appropriate credentials:
SettingValueMongoDB Agent UsernameEnter the MongoDB Agent username.
MongoDB Agent PasswordEnter the password for the MongoDB Agent username.
Configure Deployments Not Managed by Automation
Each MongoDB Agent function uses a different set of MongoDB shell (mongosh) commands to configure a user with the appropriate roles and privileges.
User creation commands vary depending on the version of MongoDB that you use:
Configure Backup Credentials
After you create the user for the Backup function, add the credentials to the Backup Settings.
Navigate to Backup <backup-deployment> Edit Credentials.
Click Credentials.
Add the appropriate credentials:
SettingValueBackup UsernameEnter the Backup username.
Backup PasswordEnter the password for the Backup username.
Configure Deployments Not Managed by Automation
Each MongoDB Agent function uses a different set of MongoDB shell (mongosh) commands to configure a user with the appropriate roles and privileges.
To monitor MongoDB 4.0 or later instances that use SCRAM authentication, add a user to the admin database in MongoDB. Assign this user the roles provided in the following example.
db.getSiblingDB("admin").createUser( { user: "<username>", pwd: "<password>", roles: [ { role: "clusterMonitor", db: "admin" } ] } )
Note
For Cloud Manager projects that contain a sharded cluster with MongoDB 8.0 or greater feature compatibility version, the monitoring agent requires the directShardOperations role if the cluster has:
Two or more shards
At least one non-system database
This role allows the monitoring agent to perform necessary maintenance and diagnostic operations directly on the shards.
This requirement is specific to Cloud Manager. If you are using Atlas, Atlas manages these permissions automatically.
db.getSiblingDB("admin").createUser( { user: "<username>", pwd: "<password>", roles: [ { role: "clusterMonitor", db: "admin" }, { role: "directShardOperations", db: "admin" } ] } )
To learn what roles this function requires, see Monitoring settings.
Configure Monitoring Credentials
After you create the user for the Monitoring function, add the credentials to the Monitoring Settings.
In MongoDB Cloud Manager, go to the Processes page for your project.
If it's not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.
If it's not already displayed, select your desired project from the Projects menu in the navigation bar.
In the sidebar, click Processes under the Database heading.
The Processes page displays.
Click the , and then Monitoring Settings.
Click Credentials.
Add the appropriate credentials:
SettingValueMonitoring UsernameEnter the Monitoring username.
Monitoring PasswordEnter the password for the Monitoring username.