Skip to content

Error refreshing state #37

Open
Open
@aellwein

Description

@aellwein

Hi,
i am trying out terraform-backend-git v0.1.4 on a M1 Mac.

For the backend, i've created a script on PATHcalled tfbg with following content:

#!/bin/sh
ssh-agent  # this is probably not needed
terraform-backend-git -l git terraform "$@"

In a terraform folder in my repo, i've created a terraform-backend-git.hcl file with following content:

git.repository = "ssh://CEPBEPOK/~alex/git/infra_state.git"
git.ref = "main"
git.state = "/tfstate.json"

Upon using tfbg init, i get a git_http_backend_auto.tf file created:

terraform {
	backend "http" {
		address = "http://localhost:6061/?type=git&repository=ssh://CEPBEPOK/~alex/git/infra_state.git&ref=main&state=/tfstate.json"
		lock_address = "http://localhost:6061/?type=git&repository=ssh://CEPBEPOK/~alex/git/infra_state.git&ref=main&state=/tfstate.json"
		unlock_address = "http://localhost:6061/?type=git&repository=ssh://CEPBEPOK/~alex/git/infra_state.git&ref=main&state=/tfstate.json"
		skip_cert_verification = false
		username = ""
		password = ""
	}
}

But the command execution leaves me with following:

[terraform-backend-git]: Using config file: /Users/alex/git/infra/terraform/terraform-backend-git.hcl
[terraform-backend-git]: WARNING: HTTP basic auth is disabled, please specify TF_BACKEND_GIT_HTTP_USERNAME and TF_BACKEND_GIT_HTTP_PASSWORD
[terraform-backend-git]: listen on 127.0.0.1:6061

Initializing the backend...
[terraform-backend-git]: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
[terraform-backend-git]: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
[terraform-backend-git]: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
Error refreshing state: Failed to get state: GET http://localhost:6061/?type=git&repository=ssh://CEPBEPOK/~alex/git/infra_state.git&ref=main&state=/tfstate.json giving up after 3 attempt(s)
Error: exit status 1

Looks like something is going wrong on the SSH level.
Cloning the infra_state.git repo from the command line works just fine (BTW it's a bare repository).

P.S.: Maybe worth mentioning: the CEPBEPOK hostname is not directly resolvable; it's defined in some ~/.ssh/config file of mine (it's a server located on my local network). As being said, the git clone works without any issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions