Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect to MongoDB: Unknown option username | ConfigurationError: Unknown option username #370

Closed
cy83rs30rd opened this issue Jul 18, 2019 · 6 comments

Comments

@cy83rs30rd
Copy link

Issues:
From cuckoo startup:

2019-07-18 13:04:54,986 [modules.reporting.retention] WARNING: Unable to connect to MongoDB: Unknown option username

From running webserver:

System check identified no issues (0 silenced).
July 18, 2019 - 12:13:40
Django version 1.8.4, using settings 'web.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
/usr/local/lib/python2.7/dist-packages/ratelimit/middleware.py:2: RemovedInDjango19Warning: django.utils.importlib will be removed in Django 1.9.
  from django.utils.importlib import import_module

Internal Server Error: /
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 119, in get_response
    resolver_match = resolver.resolve(request.path_info)
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 366, in resolve
    for pattern in self.url_patterns:
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 402, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 396, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/cuckoo/CAPE/web/web/urls.py", line 14, in <module>
    from compare import urls as compare
  File "/home/cuckoo/CAPE/web/compare/urls.py", line 6, in <module>
    from compare import views
  File "/home/cuckoo/CAPE/web/compare/views.py", line 32, in <module>
    authSource=settings.MONGO_DB)[settings.MONGO_DB]
  File "/usr/local/lib/python2.7/dist-packages/pymongo/mongo_client.py", line 322, in __init__
    username, password, dbase, opts)
  File "/usr/local/lib/python2.7/dist-packages/pymongo/client_options.py", line 108, in __init__
    options = dict([validate(opt, val) for opt, val in iteritems(options)])
  File "/usr/local/lib/python2.7/dist-packages/pymongo/common.py", line 452, in validate
    value = validator(option, value)
  File "/usr/local/lib/python2.7/dist-packages/pymongo/common.py", line 100, in raise_config_error
    raise ConfigurationError("Unknown option %s" % (key,))
ConfigurationError: Unknown option username

What I've tried so far:
I'm running MongoDB server version: 3.4.21
I've setup a user and tested connection via the following command
mongo --host <Ip_address>:27017 -u -p password --authenticationDatabase cuckoo
It successfully connects and shows the following message

MongoDB shell version v3.4.21
connecting to: mongodb://<Ip_address:27017/
MongoDB server version: 3.4.21
>

I've entered the username and password into CAPE/conf/reporting.conf
I've tested with and without username and password and same result is happening.

Is anyone else having issues with the MongoDB authentication?
It appears MongoDB authentication was added in the following commit.
a483cf9#diff-b4ef698db8ca845e5845c4618278f29a

Any help, much obliged.

@kevoreilly
Copy link
Contributor

Hmm you are right to suspect the mongo auth commit as likely being responsible. Let me try to work out what's going on.

@cy83rs30rd
Copy link
Author

I know it's oaf but I tested with MongoDB version 2.6.10 as well, was getting same issue

@kevoreilly
Copy link
Contributor

Please let me know if you have made any progress on this issue - I haven't heard of any others having this problem, nor have I seen it myself. I plan to close this issue soon as doesn't seem to be widespread.

@Godlance
Copy link

Godlance commented Oct 2, 2019

Our team faced this issue yesterday.

We had to do perform several steps to solve it, but keep in mind that they could be unrelated as we could not isolate the main issue.

1.- Make sure that your mongodb folders (located in subdirectories of /data and /var) have the proper ownership and permissions (i.e. sudo chown -R mongodb:mongodb /data/sandbox/mongodb/).

2.- Make sure that the mongodb service is disabled and stopped, as it conflicts with the newer mongod service (i.e.sudo systemctl stop mongodb && sudo systemctl disable mongodb). This is due to a recent mongo update and is a pretty obscure piece of information that is hard to come around.

3.- Make sure (via netstat) that if you stop the mongod service there is no other process listening on port 27017.

4.- If everything else fails, test your luck installing flask-pymongo via pip, as some of it dependencies may help you (but this could be a real lucky shot).

Hope it helps.

@doomedraven
Copy link
Contributor

@Godlance thanks for info, i have updated the install script https://github.com/doomedraven/Tools/blob/master/Cuckoo/cuckoo.sh#L375

@kevoreilly
Copy link
Contributor

Looks like this issue has been taken care of - thanks all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants