Amol M Kulkarni
Amol M Kulkarni

Reputation: 21629

How to protect development MongoDB server with password?

I want to protect my development MongoDB server with password, which I am using with mongoose. I know how to set the password at Database level. But I required at MongoDB server itself.

In what way I should do it?

Upvotes: 1

Views: 189

Answers (1)

Amol M Kulkarni
Amol M Kulkarni

Reputation: 21629

To force MongoDB to use authentication you will need to add the –-auth parameter to MongoDB at service start-up.

If you are using an unauthorized user you will get an error or if you try to do something like list the available database on the server 'show dbs' you will get same error

error: { “$err” : “unauthorized for db [mydatabase] lock type: -1 ” }

MongoDB server connection in the sense it uses admin database to connect first, then you can list the dbs. So to get db list you will need to make sure you switch to an account with read/write privileges in admin.

But --auth will be an forced authentication on each and every connections.

Happy exploring...

For more Info: http://docs.mongodb.org/manual/administration/security/#authentication

Upvotes: 3

Related Questions