Master MongoDB authentication methods including SCRAM, X.509 certificates, LDAP, and Kerberos. Learn user creation, role assignment, and securing MongoDB deployments.
Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
Der Befehl bleibt in einer Zeile. Scrollen Sie horizontal, um ihn vor dem Kopieren vollständig zu prüfen.
Sie bevorzugen eine lokale Kopie? Laden Sie die Dateien herunter, die SkillsMP derzeit vorliegen.
Datei-Explorer
4 Dateien
SKILL.md wird angezeigt
SKILL.md
Quellanweisungen · Schreibgeschützte Vorschau
name
mongodb-authentication
version
2.1.0
description
Master MongoDB authentication methods including SCRAM, X.509 certificates, LDAP, and Kerberos. Learn user creation, role assignment, and securing MongoDB deployments.
{"common_errors":[{"code":"AUTH001","condition":"Authentication failed","recovery":"Verify username, password, authSource database"},{"code":"AUTH002","condition":"User not found","recovery":"Check user exists in correct authenticationDatabase"},{"code":"AUTH003","condition":"Password policy violation","recovery":"Ensure password meets complexity requirements"}]}
prerequisites
{"mongodb_version":"4.0+","required_knowledge":["mongodb-basics","user-management"],"security_requirements":["mongod started with --auth or authorization: enabled"]}
# Start MongoDB with authentication
mongod --auth --dbpath /data/db
# Or in config file (mongod.conf)
security:
authorization: enabled
Create Admin User
// Connect to local server without auth firstconst mongo = newMongoClient('mongodb://localhost:27017')
const admin = mongo.db('admin')
// Create admin userawait admin.command({
createUser: 'admin',
pwd: 'securepassword', // Or use passwordPrompt()roles: ['root']
})
// Now restart mongod --auth
Authentication Methods
SCRAM (Salted Challenge Response)
// Default, password-based authentication// Connection stringmongodb://username:password@localhost:27017/database// With optionsmongodb://username:password@localhost:27017/database?authSource=admin// Create SCRAM user
db.createUser({
user: 'appuser',
pwd: 'password123',
roles: ['readWrite']
})
// Requirements for production:// ✅ Minimum 12 characters// ✅ Mix of uppercase, lowercase, numbers, symbols// ✅ No dictionary words// ✅ Not related to username// Example strong password// P@ssw0rd2024!MongoDB// DON'T USE// password, 123456, monkey, qwerty, password123
Password Rotation
// Change passwords regularly// Monthly for service accounts// Quarterly for normal users// Update password
db.changeUserPassword('username', 'newpassword')
// Check user details
db.getUser('username')
Connection with Authentication
MongoDB Shell
# Connect with authentication
mongosh --username admin --password --authenticationDatabase admin mongodb://localhost:27017
# Or with connection string
mongosh 'mongodb://admin:password@localhost:27017/?authSource=admin'