Internal communication using SCRAM

In order to secure communications between members of a replica set or sharded cluster, you need to create a keyfile (https://docs.mongodb.com/manual/core/security-internal-authentication/#keyfiles). The keyfile will then need to be copied to each member of the set or cluster.  The length of each key can be from 6 to 1,024 characters, and can include any character defined in RFC 4648, base64 encoding (https://tools.ietf.org/html/rfc4648#section-4).  You can then restart each member mongod instance after adding the following to its MongoDB config file:

security:     keyFile: <path/to/key/file>

Alternatively, you can restart the mongod instance with the following command-line switch:

--keyFile <path-to-keyfile> ...

Get MongoDB 4 Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.