Log in to a host
turf login <hostname> gets an API token for a Terraform®-compatible host, such as a private module
registry or a remote state backend (HashiCorp’s hosted or self-managed platform, Scalr), and saves it.
turf logout <hostname> removes it again. Like tofu login, both need an explicit hostname; neither guesses a default.
turf login app.terraform.ioturf logout app.terraform.ioWhere the token goes
Section titled “Where the token goes”The token is written to credentials.tfrc.json in your OpenTofu® and Terraform CLI configuration
directory, in the format those tools write, so a co-installed tofu or terraform reads exactly what
Turf™ stores, and the other way round.
| Platform | Path |
|---|---|
| macOS, Linux | ~/.terraform.d/credentials.tfrc.json |
Linux, a fresh install with XDG_CONFIG_HOME set and no ~/.terraform.d |
$XDG_CONFIG_HOME/opentofu/credentials.tfrc.json |
| Windows | %APPDATA%\terraform.d\credentials.tfrc.json |
The file is written with mode 0600. Settings already in it (plugin_cache_dir,
provider_installation, other hosts) are kept.
Which process reads it
Section titled “Which process reads it”Turf uses the token for its own requests to the host: remote-protocol state backends (HashiCorp’s hosted
or self-managed platform, Scalr) and the provider registry. The MCP server and the engine both read the
credentials file, so one turf login covers Turf and a co-installed tofu or terraform alike.
A TF_TOKEN_<hostname> variable (dots as underscores) works only in the environment of the process
that needs it: the server’s for the remote backend and init’s installs, the engine’s for the
installs a plan makes. Set it in both, or use the credentials file. See
State backend, registries and mirrors.
How you sign in
Section titled “How you sign in”Most hosts, HashiCorp’s hosted platform and Scalr among them, do not implement the OAuth login protocol. For those,
turf login opens the host’s user-token page and reads back the token you paste. A host that
advertises a login.v1 service gets a full OAuth 2.0 authorization-code flow with PKCE instead.
Either way, turf shows you where the token will be stored and asks before writing it.
Pipe the token in with --token-stdin:
echo "$TFE_TOKEN" | turf login --token-stdin tfe.example.comPrefer a pipe to a herestring (<<<), which some shells write to a temporary file. Without
--token-stdin, turf login refuses to run with stdin redirected, rather than wait on a prompt nobody
can answer.
Precedence
Section titled “Precedence”When a host is configured more than once, the OpenTofu order applies: a TF_TOKEN_<hostname>
environment variable wins over the credentials file, which wins over a credentials helper.
turf login warns when the token it is about to write would be shadowed by such a variable, and
turf logout warns when one will keep authenticating you after the stored token is gone.
Limits
Section titled “Limits”- turf does not detect a
credentialsblock written by hand in.terraformrcor.tofurc. Such a block keeps winning over the file turf writes, silently. - turf does not support credentials helpers.
turf logoutforgets the token locally only. It does not revoke it on the host: if it has leaked, revoke it there.
Turf™ is a trademark of Turf LLC. Terraform® is a trademark of HashiCorp. Ansible® is a trademark of Red Hat, LLC, registered in the United States and other countries. Helm®, Kubernetes®, Prometheus® and OpenTelemetry® are registered trademarks, and Jaeger™ is a trademark, of the Linux Foundation. OpenTofu® and Model Context Protocol® are registered trademarks of LF Projects, LLC. All other trademarks are the property of their respective owners. Turf is not affiliated with, endorsed by, or sponsored by HashiCorp, IBM, Red Hat, the Linux Foundation, LF Projects or the OpenTofu project.
© 2026 Turf LLC. Free for individuals, education and small businesses within the Community limits, under the Turf Community Edition License 1.0. Government and larger organizations need a commerciallicense.turf.build · Discord ·GitHub