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> ...