Navigation
You were redirected from a different version of the documentation. Click here to go back.

Configure the Backup Agent for Kerberos

MongoDB Enterprise provides support for Kerberos. Kerberos is a network authentication protocol available in MongoDB Enterprise version 2.4 or later. The Backup Agent can authenticate to MongoDB instances using Kerberos.

Important

In Ops Manager 1.8 and later, Ops Manager can manage agent authentication if Automation manages agents. Using Automation, you first need to specify the agent’s name, and, if using LDAP authorization, the LDAP group corresponding to the MongoDB role. Ops Manager creates the specified MongoDB user for each agent and configures the appropriate access for that agent user.

See Enable Kerberos Authentication for your Ops Manager Group for more information.

Prerequisites

Configure KDC to Issue Tickets with Four-Hour Minimum Lifetime

Kerberos tickets are only valid, or used to authenticate users, for a limited time. You must configure the Kerberos Key Distribution Center (KDC) to issue tickets that are valid for at least four hours. The Backup Agent periodically renews the ticket. The KDC service provides session tickets and temporary session keys to users and computers.

Add Kerberos as Authentication Mechanism for Deployment

MongoDB agents interact with the MongoDB databases in your deployment as a MongoDB user would. Each agent must be authenticated and then granted privileges according to what their roles are on your deployment. As a result, you must configure your MongoDB deployment and your agents 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 Kerberos authentication mechanism you want the agents to use.

Adding an agent as a MongoDB user requires configuring an authentication mechanism. Agents can use any supported authentication mechanism, but all agents must use the same mechanism.

For the purposes of this tutorial, you must ensure your:

  • Deployment supports Kerberos authentication and
  • Agents use Kerberos authentication.

See Enable Kerberos Authentication for your Ops Manager Group for how to enable Kerberos authentication.

Configure Backup Agent Host to Use Kerberos

Two Kerberos-related files must be installed on any host running the Monitoring or Backup Agent:

  • Create or configure the krb5.conf Kerberos configuration file.

    Platform Default Path Notes
    Linux /etc/krb5.conf  
    Mac OS X /etc/krb5.conf (10.7+) The configuration file has varied with previous versions of Mac OS X. Refer to the documentation for your Kerberos implemention for your version of Mac OS X to find out where the Kerberos configuration file is stored.
    Windows %WINDIR%\krb5.ini This is the default path for non-Active Directory-based Kerberos implementations. Refer to the documentation for your Kerberos implemention for your version of Windows to find out where the Kerberos configuration file is stored.
  • On Linux systems: ensure kinit binary is located at /usr/bin/kinit. kinit obtains or renews a Kerberos ticket-granting ticket, which authenticates the agent using Kerberos.

Create Kerberos Service Principal for the Backup Agent

1

Create or choose a Kerberos Service Principal Name for each Agent.

Create or choose a Kerberos Service Principal Name (SPN) for the agents you are running. The Monitoring and Backup agent should have their own SPNs.

An SPN is formatted in three parts so the service can be uniquely identified across the Kerberos realm:

Component Description
Service name The name of one service a host is providing to the Kerberos realm, such as mail, snmp, ftp.
Hostname The host running the service as a fully qualified domain name (FQDN).
Kerberos realm

A set of managed hosts and services that share the same Kerberos database.

Note

By Kerberos naming convention, the <KERBEROS_REALM> must be in all UPPERCASE.

Example

In a Kerberos realm set as EXAMPLE.COM, a backup agent running on the host db1.example.com would set its SPN to: backup-agent/db1.example.com@EXAMPLE.COM

2

Generate a keytab for the Kerberos Service Principal Name of each Agent.

Generate a keytab file (*.keytab) for each SPN and copy it to the host that runs the agent. Ensure the system user that runs the agent is the same system user that owns the keytab file.

Create a User and Assign Roles for the Backup Agent SPN

After creating the Kerberos SPN, create a user mapped to the agent’s SPN and grant it privileges on your MongoDB deployment.

Where you create the user depends upon if you are using LDAP authorization:

  • If you are using LDAP authorization, you must create a user and group for the agent on the LDAP server and map the LDAP group to a MongoDB role in your deployment’s admin database.
  • If you are not using LDAP authorization, you must create the agent’s user on the $external database in your MongoDB deployment.

Using LDAP to Authorize the MongoDB Agent User

If you are using LDAP Authorization in your MongoDB deployment, you must manage the MongoDB users for your agents through your LDAP Server.

Warning

When using LDAP Authorization, do not create any users in the $external database. MongoDB 3.4 does not start if there is a user in the $external database and LDAP authorization is enabled.

For each MongoDB user representing an Ops Manager agent:

  1. Create a new LDAP user on your LDAP server named with the SPN.

    See the documentation for your LDAP implementation for how you create an LDAP user.

  2. Create an LDAP group whose name matched the agent’s role exactly.

    See the documentation for your LDAP implementation for how you create an LDAP group.

  3. Create the agent’s role in your admin database with the appropriate permissions.

    See Required Access for Backup Agent and Required Access for Monitoring Agent for appropriate roles for the agents.

  4. Assign the LDAP user to the LDAP group.

    See the LDAP Roles section of the LDAP authorization page of the MongoDB manual for how to map an LDAP group and MongoDB role.

See also

See the /core/security-ldap-external page for how to enable LDAP authorization without Ops Manager automation.

Using MongoDB to Authorize the MongoDB Agent User

If you are using MongoDB to manage user authorization, you need to add each agent’s SPN as a user in $external database in your MongoDB deployment. Without LDAP authorization, MongoDB uses the $external database to authenticate a user against an external source such as Kerberos.

Note

See Required Access for Backup Agent and Required Access for Monitoring Agent for appropriate roles for the agents.

From a mongo shell connected to your MongoDB deployment, issue the following commands to create the users:

MongoDB 3.0 or Later

use $external
db.createUser(
   {
     user: "<Kerberos Principal>",
     roles: [
        { role: "backup", db: "admin" }
     ]
   }
)

MongoDB 2.6

use $external
db.createUser(
   {
     user: "<Kerberos Principal>",
     roles: [
        "clusterAdmin",
        "readAnyDatabase",
        "userAdminAnyDatabase",
        { role: "readWrite", db: "admin" },
        { role: "readWrite", db: "local" },
     ]
   }
)

See Required Access for Backup Agent for more information on the required access.

Edit the Backup Agent Configuration File

Edit the Backup Agent configuration file. The following table lists the default installation paths for some common platforms. Depending on your deployment, you may need to substitute the default path for the custom installation path used for your Ops Manager agent installation.

Platform Path
RHEL, Ubuntu /etc/mongodb-mms/backup-agent.config
Linux Archive, Mac OS X <userSelected>/local.config
Windows C:\MMSData\Backup\local.config
1

Add the krb5Principal value.

Set the krb5Principal to the Kerberos SPN for the agent.

Example

krb5Principal=<agent>-agent/db1.example.com@EXAMPLE.COM
2

Add the krb5Keytab value.

Set the krb5Keytab to the complete absolute path of the keytab file for the agent.

Example

krb5Keytab=/etc/mongodb-mms/<agent>-agent.keytab
3

Restart the agent.