$ mongo
In mongoDB shell
> use admin
> db.createUser({user:"sanocare", pwd:"sanocare123", roles:[{role:"root", db:"admin"}]})
Enable mongodb authentication
Changes in service file "mongod.service"
$ sudo nano /lib/systemd/system/mongod.service
Before :
--------
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
After :
-------
ExecStart=/usr/bin/mongod --quiet --auth --config /etc/mongod.conf
Changes in mongodb config file "mongod.conf"
$ sudo nano /etc/mongod.conf
Before :
--------
bindIp : 127.0.0.1
After : [Add the host ip addresses using the mongo instance ]
-------
bindIp: [127.0.0.1, ***************]
Amazon EC2 Instance Configuration Details
Make sure all the packages and security packages are updated