To configure MongoDB security on Ubuntu 20.04, you need to create a user with admin rights, configure authentication and test it. MongoDB (Mongo) is a database that belongs to NoSQL and stores JSON with dynamic schemas.
Mongo's security problem is that there is no authentication out of the box. Any user accessing the server with the database can add and delete data without restriction. This has a serious impact on security. For this reason, to protect against the MongoDB vulnerability in Ubuntu 20.04 you need to:
1, MongoDB database on the server.
2. Ubuntu 20.04 server without root users but with a firewall.
Step by step instructions for configuring MongoDB security:
Add a user with admin privileges. You can do this without additional settings, since authentication is disabled by default. Create the user with the db.createUser command. Basically, you form a JSON file with data (name, password, role). After creating the user, exit the MongoDB client using the exit command
Activate authentication in MongoDB config file mongod.conf. To do this, find security in the configs and select
security:
authorization: "enabled"
To activate the changes in the configs, restart the daemon.
At the final stage check Mongo authentication settings. You can check access restrictions using the show dbs command. If the authentication of the user with the previously set rights is not performed, the system will not give access to the database.