Home › Git

fatal: could not read Username for 'https://github.com': terminal prompts disabled — how to fix

fatal: could not read Username for 'https://github.com': terminal prompts disabled
fatal: could not read Username for 'https://github.com': No such device or address

Quick fix: Give Git credentials it can use without a prompt: switch to SSH with git config --global url."git@github.com:".insteadOf "https://github.com/", or configure a credential helper / token. For Go private modules also set go env -w GOPRIVATE=github.com/yourorg/*.

What it means

The remote URL is https://..., the server asked for authentication, and Git found no stored credential. Normally it would prompt for a username, but here:

The fix is to provide credentials that don't need a prompt. Note that GitHub doesn't accept account passwords over HTTPS anyway, so you need a token or SSH.

Cause 1: go get / go mod download on a private repository

Go fetches modules through the public proxy and runs git with prompts disabled. For private repos, both fail.

Fix 1

Tell Go the module is private (skips the proxy and checksum database):

go env -w GOPRIVATE=github.com/yourorg/*

Then give git a non-interactive way in. Either use SSH for all GitHub URLs (your SSH key must be loaded):

git config --global url."git@github.com:".insteadOf "https://github.com/"

or use a personal access token via ~/.netrc:

machine github.com
login your-username
password ghp_yourtoken
chmod 600 ~/.netrc

Cause 2: CI pipeline or Docker build

The runner has no stored credentials, so cloning another private repo or a private submodule fails.

Fix 2

In GitHub Actions, the actions/checkout token only covers the current repo by default. For other private repos, pass a token with access through a secret:

- uses: actions/checkout@v4
  with:
    token: ${{ secrets.PAT }}
    submodules: recursive

In other CI systems or Dockerfiles, rewrite the URL with a token from a secret variable (don't hard-code it, and don't bake it into an image layer):

git config --global url."https://x-access-token:${GH_TOKEN}@github.com/".insteadOf "https://github.com/"

For Docker builds, prefer BuildKit secrets or RUN --mount=type=ssh over build args, which end up in the image history.

Cause 3: no credential helper on your machine

On a server or WSL you typed the token once, but nothing saved it, and now a script runs git non-interactively.

Fix 3

Store credentials once, interactively:

git config --global credential.helper store     # plain text in ~/.git-credentials
git pull                                         # enter username + token once

Or use the GitHub CLI, which sets itself up as a helper:

gh auth login
gh auth setup-git

On desktops, Git Credential Manager (bundled with Git for Windows) stores tokens in the OS keychain.

Cause 4: wrong remote URL

A typo in the repo path, or a repo you have no access to, also triggers an auth prompt because GitHub answers private/missing repos the same way.

Fix 4

git remote -v
git remote set-url origin git@github.com:yourorg/repo.git

Check the repo exists and your account (or token scope) can read it.

Last updated 2026-11-30.