Authentication and Access Control
How to secure a MongoDB instance in production environments.
Enable Authentication
Steps:
1
3
Using authentication
mongodb@vm00:/home/mongodb/ [mdb01] ms
Current Mongosh Log ID: 68628382b3d1df2e6369e327
Connecting to: mongodb://127.0.0.1:27017/?tls=true&tlsCertificateKeyFile=%2Fu01%2Fapp%2Fmongodb%2Fadmin%2Fmdb01%2Fsecret%2Fmongo-x509%2Fclients%2FclientUser.pem&tlsCAFile=%2Fu01%2Fapp%2Fmongodb%2Fadmin%2Fmdb01%2Fsecret%2Fmongo-x509%2Fca%2Fca.pem&directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.5.6
Using MongoDB: 8.0.16
Using Mongosh: 2.5.6
For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/
test> use admin
switched to db admin
admin> show collections
MongoServerError[Unauthorized]: Command listCollections requires authenticationLast updated