[SERVER-3619] mongostat can't authenticate to mongos using -u -p or the long name equivalents Created: 17/Aug/11  Updated: 11/Jul/16  Resolved: 17/Aug/11

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 2.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Bernie Hackett Assignee: Kristina Chodorow (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-3641 support mongostat through mongos with... Closed
Operating System: ALL
Participants:

 Description   
  • Start up a small sharded cluster with authentication.
  • Add an admin user and make sure that user can authenticate
  • Run mongostat -u <user> -p <password>

Here's and example of what happens:

$ mongostat -u theadmin -p mypassword
connected to: 127.0.0.1
error:

{ ok: 0.0, errmsg: "unauthorized" }

$ mongostat --username theadmin --password mypassword
connected to: 127.0.0.1
error:

{ ok: 0.0, errmsg: "unauthorized" }

$ mongo
MongoDB shell version: 2.0.0-rc0-pre-
connecting to: test
> use admin
switched to db admin
> db.auth('theadmin', 'mypassword')
1

Maybe I'm missing something obvious.



 Comments   
Comment by Eliot Horowitz (Inactive) [ 25/Oct/11 ]

This is fully fixed in master.

Comment by Rene Gallati [ 25/Oct/11 ]

Ignore: Is fixed in upstream 2.0.1 (had 2.0.0 running)

Any packaged tool that does not select a database first ("use <db>") fails when using auth. When you use mongo shell manually you ALSO have to "use admin" for sa only auth systems (only user in admin db set) before you can do anything. Authenticating in general seems to be tied to databases, virtual or real ones. Thus any tool not capable of selecting a database prior to the auth attempts seems to be failing.

I am amazed how many people run without auth so that this hasn't been found earlier.

Comment by auto [ 17/Aug/11 ]

Author:

{u'login': u'kchodorow', u'name': u'Kristina', u'email': u'kristina@10gen.com'}

Message: error out nicely with mongostat+auth on mongos SERVER-3619
Branch: master
https://github.com/mongodb/mongo/commit/e52a031a3272a78e25ce71829a730ef8501a1c85

Comment by Bernie Hackett [ 17/Aug/11 ]

$ mongostat --discover -u theadmin -p mypassword

localhost:27017 serverStatus failed

localhost:27017 serverStatus failed

localhost:27017 serverStatus failed

localhost:27017 serverStatus failed

etc....

Generated at Thu Feb 08 03:03:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.