“This brief tutorial will explore the commands we can use to connect the Atlas CLI with your MongoDB Atlas deployment.
It is good to perform authentication to your development machines and restrict other addresses outside your network from accessing your cluster.
This ensures that you have sufficient security measures to protect your data.”
Atlas CLI Installation
Before you can use the Atlas commands on your machine, you need to ensure the MongoDB Atlas tools are installed on your machine.
This tutorial will install the Atlas CLI tools on the Debian system. However, you can check the MongoDB documentation for installation instructions on other systems.
Start by updating the system repositories:
Install GNUPG package.
Import MongoDB public GPG key with the command:
Create a repository file for MongoDB with the command:
Refresh the system packages:
Install MongoDB Atlas and Atlas CLI.
Verify the installation has been completed successfully and run the command below to show the current Atlas version.
The command above should return the output as shown:
git version: 2ac7d5cf94baa17b50e783a0f8a579695d9d0b4e
Go version: go1.18.2
os: linux
arch: amd64
compiler: gc
Atlas Auth Options
To perform authentication to your Atlas account, we use the atlas auth command. The command syntax is as shown:
atlas auth [command
The command supports the following flags.
-h, --help help for auth
Global Flags:
-P, --profile string Profile to use from your configuration file.
Atlas Auth Subcommands
The atlas auth commands support the following subcommands:
whoami - verify and display information about auth state
logout – log out of the atlas CLI
register – register with mongodb atlas
Atlas Login
To connect your atlas CLI with your Atlas Account, run the command:
The command will generate a verification to connect to your CLI.
To log out, use the command:
To check the currently logged-in user:
Output:
To register with the atlas:
Conclusion
This post discusses the various commands and subcommands you can use to interact with your MongoDB Atlas cluster from the command line. We discussed topics such as login commands, authentication commands, and more. Feel free to check the docs for more information.