I am having a mongodb instance running which is running auth mode in my server machine. Currently I am using a shell scipt to get whether there is a mongodb instance running or not. How Can I check whether if the mongodb is running in a auth mode or non auth mode .
相关问题
- MongoDB can not create unique sparse index (duplic
- How to get the return code of a shell script in lu
- Spring Data MongoDB - lazy access to some fields
- Golang mongodb aggregation
- Invoking Mirth Connect CLI with Powershell script
相关文章
- 使用2台跳板机的情况下如何使用scp传文件
- mongodb有没有什么办法禁止读取数据的时候进行缓存
- mongodb-aggregate聚合查询分组后如何获得多字段
- In IntelliJ IDEA, how can I create a key binding t
- mongodb error: how do I make sure that your journa
- shell中反引号 `` 赋值变量问题
- How get the time in milliseconds in FreeBSD?
- How to track MongoDB requests from a console appli
If you just want to test whether you can connect to a MongoDB server without authentication via
bash
, you can use a script similar to the following:Example output:
The only parameter for this script is an an optional MongoDB address to connect to (host:port/dbname); the
mongo
shell defaults to usinglocalhost:27017/test
.The script does a simple check on whether users can be listed without permission.
If auth is properly enabled, the
db.getUsers()
command should return an error like:Note: Localhost Exception
By default (as at MongoDB 3.0) there is a
localhost exception
that allows you to create a first user administrator for a deployment by connecting vialocalhost
. Once at least one user has been added, the localhost exception is automatically disabled.If you want to check the full security of your deployment, it's definitely worth reviewing the MongoDB Security checklist.