blob: 9a4cb535a7dbaeedf2536e8611a31565b3397bfb [file] [log] [blame]
---
page_title: terraform login command reference
description: >-
The `terraform login` command obtains an API token for HCP Terraform, Terraform Enterprise, or other host that
offers Terraform services.
---
# `terraform login` command
The `terraform login` command obtains an API token for HCP Terraform, Terraform Enterprise, or other host that
offers Terraform services.
You can only use this command in interactive scenarios because the command launches a web browser on the same host where Terraform
is running. If you are running Terraform in an unattended automation scenario,
you can
[configure credentials manually in the CLI configuration](/terraform/cli/config/config-file#credentials).
## Usage
Usage: `terraform login [hostname]`
If you don't provide an explicit hostname, Terraform will assume you want to
log in to HCP Terraform at `app.terraform.io`.
## Credentials Storage
By default, Terraform will obtain an API token and save it in plain text in a
local CLI configuration file called `credentials.tfrc.json`. When you run
`terraform login`, it will explain specifically where it intends to save
the API token and give you a chance to cancel if the current configuration is
not as desired.
If you do not wish to store your API token in the default location, you can
optionally configure a
[credentials helper program](/terraform/cli/config/config-file#credentials-helpers) that knows
how to store and later retrieve credentials in some other system, such as
your organization's existing secrets management system.
## Login Server Support
The `terraform login` command works with any server supporting the
[login protocol](/terraform/internals/login-protocol), including HCP Terraform
and Terraform Enterprise.