Hi, is there any way to avoid getting a password prompt via the mongosh when authMechanism=MONGODB-X509 is passed?
$ ./mongosh --tls --tlsAllowInvalidCertificates --tlsAllowInvalidHostnames --tlsCertificateKeyFile=/home/test/root.pem --authenticationMechanism=MONGODB-X509 --authenticationDatabase='$external' --username='CN=root,OU=user,O=TestCompany,L=New York,ST=New York,C=US' localhost:27017/admin
Enter password: # <- would like to get rid of this prompt
Current Mongosh Log ID: xxxxxxxxxxxxxxxxxxxxxxxx
I tried to reproduce the issue in my local environment using the documentations available for a test environment, however I was not successful in reproducing the password prompt that you are seeing. That is, using authMechanism=MONGODB-X509 does not produce a password prompt for me. I am using MongoDB 6.0.1.
Could you help me with the steps or the documentations you are following and observing the same.
Also, it would be great if you could help with the following details:
MongoDB and mongosh version you are using.
command to create user.
Please refer to the following documentations for reference:
Then, I think I found the root cause. I was passing both --authenticationMechanism=MONGODB-X509 and --username='CN=root,OU=user,O=TestCompany,L=New York,ST=New York,C=US' then --username part expected to come with password as well. After removing the --username part, I’m no longer seeing the password prompt!
Maybe would it be helpful if mongosh errors out if it gets both --authenticationMechanism and --username?