Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongo Authentication

Tags:

mongodb

I have set up two servers s1 and s2. s1 is the server that a web server is running on while s2 is the server that my mongodb is running on. I have set up authentication on the mongo instance for security. When I try to connect to the mongo instance on s2 from s1 i get errors when trying to authenticate.

If I use:

mongo DB --host HOST --port PORT -u USER -p PASSWORD 
--authenticationDatabase DB --authenticationMechanism SCRAM-SHA-1

I get this error:

Error: 2 SASL authentication support not compiled into client library.
at src/mongo/shell/db.js:228
exception: login failed

If I use:

mongo DB --host HOST --port PORT -u USER -p PASSWORD 
--authenticationDatabase DB

I get this error:

Error: 18 { ok: 0.0, errmsg: "Challenge-response authentication using 
getnonce and authenticate commands is disabled.", code: 2 } at 
src/mongo/shell/db.js:228
exception: login failed

If I use:

mongo DB --host HOST --port PORT

I get in but then I need to use db.auth in order to do anything and then I get this error:

Error: 18 { ok: 0.0, errmsg: "Challenge-response authentication using 
getnonce and authenticate commands is disabled.", code: 2 }

I have no idea why I can't get in. Can someone help with this?

like image 477
Infernobass7 Avatar asked Jul 03 '15 18:07

Infernobass7


1 Answers

The problem is to do with wrong version of mongo client. check the version using the command

mongo --version

I have had problems while logging into mogodb on https://mlab.com/

The following fixed my problem and I am on Ubuntu xenial

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
sudo apt-get update
sudo apt-get install mongodb-org
like image 75
neo Avatar answered Oct 11 '22 23:10

neo