MongoDB 4.4 – Setup User Auth settings

Exported on 19-Aug-2021 14:41:40

Parameters

Name Type Script Reference Default Value Comment
Linux Node Linux / Unix Server linuxNode
Linux User Linux OS Credential linuxUser

1 - Push mongodb auth config files

The connection details have changed from the last step.

Login as user on node

Connect via SSH
ssh user@hostname
Deploy archive MongoDB - Auth Config Files.zip to remote path files/
  1. Locate Files archive "MongoDB - Auth Config Files.zip", This can be downloaded from Attune
  2. Copy the Files archive to the server
  3. Extract the root of the Files archive to files/, relative to the home directory
  4. Check that the files are in the correct location

2 - List all database on Mongo host

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
echo 'db.adminCommand( { listDatabases: 1 } )' | mongo

3 - Create admin user

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
sh files/setup-user.sh

4 - Enable Auth to mongo.conf file

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
sudo rm -rf /etc/mongod.conf
sudo cp files/mongod.conf /etc/mongod.conf
sudo service mongod restart