Connect with mongosh

Open a mongosh session against a TeselaDB node with TLS and a user.

Open a mongosh session against TeselaDB to query and administer the cluster by hand. mongosh is the MongoDB shell and works unchanged.

Requirements

  • mongosh installed; it comes from the MongoDB website.
  • The address of a node, a user with its password and the pki/ca.pem file of the cluster.

Open the session

Shell
mongosh "mongodb://root:<password>@127.0.0.1:27017/?tls=true&tlsCAFile=./ca.pem"

To keep the password out of the history, take it out of the string and add --password; mongosh will ask for it.

Check

JavaScript
db.runCommand({ connectionStatus: 1 });

The response carries in authInfo.authenticatedUsers the user you logged in as, along with the database it authenticates against.

Common problems

  • The connection closes before authenticating because tls=true is missing from the string.
  • mongosh does not trust the node certificate because tlsCAFile does not point to the pki/ca.pem of this cluster.

See also