Report this

What is the reason for this report?

How do I properly secure mongodb?

Posted on April 6, 2015

I have taken the steps provided by many of the pages over at mongodb’s official site. I still cannot seem to make it work. I posted a question on stack over flow too, because I don’t know where this really belongs. I used DO’s One Click installer, so I will post the question here as well: http://stackoverflow.com/questions/29465358/unable-to-authenticate-mongodb-remotely

I am unable to authenticate mongodb remotely. I’m running Mongoid 3.0.0 provided by the DigitalOcean One-Click installer, and I can’t seem to set up authentication properly.

I have 1 database called wbio_production. I followed mongodb docs tutorials as best as I could. When I execute:

> db.auth("siteUserAdmin","MYPASSWORD")
1
> db.getUsers()

The output of that is:

{
    "_id" : "admin.siteUserAdmin",
    "user" : "siteUserAdmin",
    "db" : "admin",
    "roles" : [
        {
            "role" : "userAdminAnyDatabase",
            "db" : "admin"
        }
    ]
} 

And when I switch to the wbio_production database and perform the same getUsers():

> use wbio_production
switched to db wbio_production
> db.getUsers()
[
    {
        "_id" : "wbio_production.herokuUser",
        "user" : "herokuUser",
        "db" : "wbio_production",
        "roles" : [
            {
                "role" : "userAdmin",
                "db" : "wbio_production"
            },
            {
                "role" : "readWrite",
                "db" : "wbio_production"
            }
        ]
    }
]

When I fill out the connection form in Robomongo however, it cannot successfully connect to the database. Authorization always fails, however it does successfully connect to the database.

I have tried the following combinations of using the users above:

DB: Admin, User: siteUserAdmin DB: Admin, User: herokuUser DB: wbio_production, User: siteUserAdmin DB: wbio_production, User: herokuUser All of them wind up with some output coming back in the heroku logs similar:

failed with error 13: "not authorized for query on wbio_production.mongoid_forums_forums"

I have tried reinstalling mongodb, recreating users based off different tutorials, and just trying different peoples explanations. I’ve spent about 5 hours now looking for a solution to my issue, and now I must turn to SO for your advice. I’m sure this is a simple error on my part that I am not understanding from the docs or something I am continuously missing in the set up.

What must I do to get a secured and functional MongoDB server? Thanks!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.