Consul Cli Login

How do I login to consul from the cli using the username password?

tried this but does not work
CONSUL_HTTP_AUTH=username:password ./consul login -http-addr ‘https://domainame’ -method=basic

Hi @mitangelo,

The CONSUL_HTTP_AUTH environment variable is only needed when you have a reverse proxy in front of Consul’s HTTP API that requires Basic Authentication. In such a configuration, you would need to provide the following credentials in order to login to Consul.

# Authentication credentials required by reverse proxy
export CONSUL_HTTP_AUTH="username:password"

# Authentication token required by Consul
export CONSUL_HTTP_TOKEN=<token>

$ consul catalog services
<service list>

The consul login command is used for authenticating to Consul via a supported auth method. Consul will validate the provided authentication credential, and if valid, exchange it for a Consul token with the appropriate permissions for the matching binding rule.

See the following post for a more detailed explanation of how the Kubernetes auth method works in Consul. The other auth methods follow a similar login flow.

Thank you @blake

I am trying to login from the cli. Using the command I mentioned to you earlier I get the following error. Missing required ‘-token-sink-file’ flag

CONSUL_HTTP_TOKEN where is this obtained from?

I did however manage to interact with the kv store…after exporting the CONSUL_HTTP_AUTH. I am assuming this is all that is needed to interact with consul if basic auth has been setup?

You would only need this if Consul’s ACL system has been enabled. (We recommend enabling ACLs in production environments.)

If ACLs are not enabled, and HTTP Basic Auth is the only authentication protecting your Consul cluster, then setting CONSUL_HTTP_AUTH is sufficient for your particular configuration.

Thank you @blake . So I dont need to to do consul auth if I have CONSUL_HTTP_AUTH set?