ChangeUserPassword() authentication fails

hi, For the M103 lab, am perfectly able to connect to port 27000 and loginto mongod & mongos. Once am into admin db, am unable to authenticate for the new user created- m103-application-user… i did read through similar postings wherein it was suggested to change password…so i did that as well as below and still it FAILS and am unable to changeUserPassword… please review and suggest where am messing up?

MongoDB Enterprise > use admin
switched to db admin
MongoDB Enterprise > db.auth(“m103-application-user”," m103-application-pass")
Error: Authentication failed.
0
MongoDB Enterprise > db.changeUserPassword(“m103-application-user”,“m103-new-pass”)
2019-12-02T08:53:52.864+0000 E QUERY [thread1] Error: Updating user failed: User m103-application-user@admin not found :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.updateUser@src/mongo/shell/db.js:1487:15
DB.prototype.changeUserPassword@src/mongo/shell/db.js:1491:9
@(shell):1:1

also i missed to add this - yes my new user added DOES exist :slight_smile:

MongoDB Enterprise > db.getUsers()
[
{
“_id” : “admin.m103-admin”,
“userId” : UUID(“b8ca9b13-9b56-4540-aba6-20cb13f45668”),
“user” : “m103-admin”,
“db” : “admin”,
“roles” : [
{
“role” : “root”,
“db” : “admin”
}
]
},
{
“_id” : “admin.m103-applicaton-user”,
“userId” : UUID(“ca9c19f1-2c76-46cb-ae45-04c6af590b00”),
“user” : “m103-applicaton-user”,
“db” : “admin”,
“roles” : [
{
“role” : “readWrite”,
“db” : “applicationData”
}
]
}
]

Maybe you’re not the one who’s messing up @sunder1 :wink:

It’s one of two things: you mistakenly created the user under the default test db, or mistakenly typed in a wrong username/password during creation.

Try this and show the result:
use test
db.auth(“m103-application-user”," m103-application-pass")

i see a leading SPACE in password field in your reply…so i too have added that

MongoDB Enterprise > use test
switched to db test
MongoDB Enterprise > db.auth(“m103-application-user”," m103-application-pass")
Error: Authentication failed.
0

Good spot! I didn’t notice that, however, it’s a copy and paste from your initial post so that could be the problem. Remove it and try again with both admin and test db.

vagrant@m103:~$ mongo admin --host 192.168.103.100:27000 -u m103-admin -p m103-pass
MongoDB shell version v3.6.15
connecting to: mongodb://192.168.103.100:27000/admin?gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“d1d5cd9f-ecfe-436b-8cd3-289b3315e152”) }
MongoDB server version: 3.6.15
Server has startup warnings:
2019-12-01T18:16:52.714+0000 I STORAGE [initandlisten]
2019-12-01T18:16:52.714+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-12-01T18:16:52.714+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-12-01T18:16:53.473+0000 I CONTROL [initandlisten]
2019-12-01T18:16:53.473+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.
2019-12-01T18:16:53.473+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-12-01T18:16:53.473+0000 I CONTROL [initandlisten]
2019-12-01T18:16:53.473+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’.
2019-12-01T18:16:53.473+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-12-01T18:16:53.473+0000 I CONTROL [initandlisten]
MongoDB Enterprise > use admin
switched to db admin
MongoDB Enterprise > db.auth(“m103-application-user”,“m103-application-pass”)
2019-12-02T09:28:54.522+0000 E QUERY [thread1] SyntaxError: illegal character @(shell):1:8
MongoDB Enterprise > use test
switched to db test
MongoDB Enterprise > db.auth(“m103-application-user”,“m103-application-pass”)
2019-12-02T09:30:00.619+0000 E QUERY [thread1] SyntaxError: illegal character @(shell):1:8
MongoDB Enterprise >

Change the quotes and try again:
db.auth("m103-application-user","m103-application-pass")

By the way, you might want to edit your thread and link it to the course.

MongoDB server version: 3.6.15
Server has startup warnings:
2019-12-01T18:16:52.714+0000 I STORAGE [initandlisten]
2019-12-01T18:16:52.714+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-12-01T18:16:52.714+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-12-01T18:16:53.473+0000 I CONTROL [initandlisten]
2019-12-01T18:16:53.473+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.
2019-12-01T18:16:53.473+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-12-01T18:16:53.473+0000 I CONTROL [initandlisten]
2019-12-01T18:16:53.473+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’.
2019-12-01T18:16:53.473+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-12-01T18:16:53.473+0000 I CONTROL [initandlisten]
MongoDB Enterprise > use admin
switched to db admin
MongoDB Enterprise > db.auth(“m103-application-user”,“m103-application-pass”)
2019-12-02T09:28:54.522+0000 E QUERY [thread1] SyntaxError: illegal character @(shell):1:8
MongoDB Enterprise > use test
switched to db test
MongoDB Enterprise > db.auth(“m103-application-user”,“m103-application-pass”)
2019-12-02T09:30:00.619+0000 E QUERY [thread1] SyntaxError: illegal character @(shell):1:8
MongoDB Enterprise > mongostat --port 27000
2019-12-02T09:34:42.208+0000 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:12
MongoDB Enterprise > use admin
switched to db admin
MongoDB Enterprise > db.auth(“m103-application-user”,“m103-application-pass”)
Error: Authentication failed.
0
MongoDB Enterprise > use test
switched to db test
MongoDB Enterprise > db.auth(“m103-application-user”,“m103-application-pass”)
Error: Authentication failed.
0

Are you sure that you have internal authentication enabled? Run the following:
use admin
show dbs
db.getUsers()

NB: please only take a screenshot of relevant parts, not the entire screen.

MongoDB Enterprise > cls
MongoDB Enterprise > use admin
switched to db admin
MongoDB Enterprise > show dbs
admin 0.000GB
config 0.000GB
demo 0.000GB
local 0.000GB
MongoDB Enterprise > db.getUsers()
[
{
“_id” : “admin.m103-admin”,
“userId” : UUID(“b8ca9b13-9b56-4540-aba6-20cb13f45668”),
“user” : “m103-admin”,
“db” : “admin”,
“roles” : [
{
“role” : “root”,
“db” : “admin”
}
]
},
{
“_id” : “admin.m103-applicaton-user”,
“userId” : UUID(“ca9c19f1-2c76-46cb-ae45-04c6af590b00”),
“user” : “m103-applicaton-user”,
“db” : “admin”,
“roles” : [
{
“role” : “readWrite”,
“db” : “applicationData”
}
]
}
]
MongoDB Enterprise >

This was a question by the way.

vagrant@m103:~$ cat /etc/mongod.conf

mongod.conf

for documentation of all options, see:

http://docs.mongodb.org/manual/reference/configuration-options/

Where and how to store data.

storage:
dbPath: /var/mongodb/db
journal:
enabled: true

engine:

mmapv1:

wiredTiger:

where to write logging data.

systemLog:
destination: file
logAppend: true
#path: /var/log/mongodb/mongod.log
path: /var/mongodb/db/mongod.log
#option : processManagement.mode

network interfaces

net:
port: 27000
bindIp: 127.0.0.1,192.168.103.100

how the process runs

processManagement:
fork : true

timeZoneInfo: /usr/share/zoneinfo

#security:

operationProfiling:
mode: “slowOp”
slowOpThresholdMs: 50
slowOpSampleRate: 1.0
#replication:

#sharding:

Enterprise-Only Options:

#auditLog:

#snmp:

security:
authorization: enabled

In the future, please paste your code inside 3 backtick blocks so that it’s easier to read. Here’s a screenshot how:
image
That way, it will preserve indentation.

What’s the title of the lab that you’re doing?

Title of the Lab - Creating First Application User

Hi @sunder1,

I believe you had a typo at the time of creating the user.

This is your username : "user" : "m103-applicaton-user".

Notice the missing i in the username.

And you are trying to authenticate against this username "user" : "m103-application-user".

Please try to authenticate with this username m103-applicaton-user and hopefully you should be able to authenticate. But, for this lab I will recommend you to recreate the user with the correct username.

Hope it helps!

If you still have any query then please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

1 Like

Good spot @Shubham_Ranjan! Goes back to my first post.

1 Like

Good catch @Shubham_Ranjan & @007_jb and thank you very much for your time !
its going to take sometime for me to forget this episode:( my bad

I’ll be having nightmares about it :sleeping: :wink: