Login from mongo command to a mongodb instance that have x509 authentication enabled

Hi all,

how do I log in and authorise to the mongo shell directly if the mongodb instance that have x509 authentication enabled instead of first login to the mongo shell and then issue the following command

db.getSiblingDB("$external").runCommand({createUser: “C=US,ST=New York,L=New York City,O=MongoDB,OU=University2,CN=M310 Client”, roles: [{ role: ‘root’, db: ‘admin’} ]})

I used the following command and it failed to authorise:

mongo --host database.m310.mongodb.university:31130 --ssl --sslPEMKeyFile /home/vagrant/shared/certs/client.pem --sslCAFile /home/vagrant/shared/certs/ca.pem --authenticationMechanism MONGODB-X509 --authenticationDatabase $external --user ‘C=US,ST=New York,L=New York City,O=MongoDB,OU=University2,CN=M310 Client’


Hi @Tony_Yesudas_75016,

Suggest you re-watch the Enabling X.509 lecture and follow the steps whilst doing the lab. You’ll find the exact mongo command that was used.

NB: It’s also against forum guidelines to post potential answers to labs

I have watched the details . it is not there that is why I have asked .

If this is how the answer is then I think this discussion system is waste.


At 2:48 from the lecture:

At 4:16 in the same lecture:

I wouldn’t have suggested re-watching the lecture video if it wasn’t there. It’s the same video that I used to complete this lab a couple of months ago.

In my view, this is not a typical online forum where answers are given to you. It’s a “University” of sorts where students are expected to complete labs and exams on their own (or with some assistance from their peers) and in the end, attain a course completion proof. If one of your peers is suggesting/hinting at something, take it in good stride and do it, then come back with more questions if you’re still struggling.

A better response from you would have been, “I’ve gone through the lecture again but still struggling. Can you please advise where in the video I can find some of those hints/tips”.

1 Like

Hi @Tony_Yesudas_75016,

I would also recommend you to go through the detailed answer from “See detailed answer” in the lab.

Thanks @007_jb for pointing the user to the video lecture.


this it worst type of discussion forum I have seen. Without understanding my question and saying you look there , you look here in the video and not in the “See detailed answer” . you guys don’t even don’t know what you have put in a tutorial.
My worst decision I thought of putting my query here . I thought there is people with knowledge to guide in the forum . Both the moderator and tutors are the same .

Hi @Tony_Yesudas_75016,

I apologise for the frustration caused to you.

We point all the users to lectures and documentation links first, to enable them to figure out solutions on their own.
However, if the user still struggles to figure out the solution, then we provide them with useful hints.

Since, we refrain ourselves from stating potential answers in the discussion forum, please check your discourse inbox for the answer that you expect.

If you still have any confusion, please feel free to post and we can help you further.


1 Like