«go get» and GitHub: Breaking Down the «terminal prompts disabled» Wall

Online Python Trainer for Beginners

Learn Python easily without overwhelming theory. Solve practical tasks with automatic checking, get hints in Russian, and write code directly in your browser — no installation required.

Start Course

Introduction: When a simple go get turns into a puzzle

\n\n

Have you ever tried to run go get github.com/your-account/private-repository and received a cold, unfriendly message in response?

\n\n
go get github.com/your-account/private-repository: \n  module github.com/your-account/private-repository: \n  git ls-remote -q origin in /tmp/...: exit status 128:\n    remote: Invalid username or password.\n    fatal: Authentication failed for 'https://github.com/your-account/private-repository.git'
\n\n

Or, even more mysteriously:

\n
go get github.com/your-account/private-repository: \n  terminal prompts disabled\n  Confirm the import path was entered correctly.\n  If this is a private repo, see https://golang.org/doc/faq#git_https
\n\n

Sound familiar? If so, you've come to the right place. This error is a classic stumbling block for Go developers working with private repositories on GitHub. On Stack Overflow, this question has gathered thousands of views, and today we'll break it down once and for all.

\n\n

In this article, we won't just solve the problem — we'll understand why it occurs, and learn to configure our environment so that go get works with private repositories like a charm. Let's go!

\n\n

Why does Go refuse to work with private repositories?

\n\n

To understand the cause, we need to look under the hood of Go. When you run go get, the Go toolchain does several things:

\n\n
    \n
  1. It tries to clone the repository via HTTPS (the default protocol).
  2. \n
  3. If the repository is private, Git requests authentication (username/password).
  4. \n
  5. By default, Go disables interactive terminal prompts — this is the very "terminal prompts disabled" message.
  6. \n
\n\n

Why does Go do this? It's simple: during automated builds or in CI/CD pipelines, interactive password input is impossible. Therefore, Go prefers to fail with an error rather than hang waiting for input.

\n\n

Key idea: The "terminal prompts disabled" error is not a bug, but a feature. Go is telling you: "I can't ask you for a password, give me ready-made credentials." And our task is to provide them.

\n\n

Method 1: Using SSH (the most reliable and correct way)

\n\n

This is the recommended method. SSH keys are secure, convenient, and don't require entering a password every time.

\n\n

Step 1. Generate an SSH key (if you don't have one)

\n

Open your terminal and run:

\n
ssh-keygen -t ed25519 -C "your_email@example.com"
\n

Press Enter to save the key to the default folder (~/.ssh/id_ed25519). You can add a passphrase — this will increase security.

\n\n

Step 2. Add the key to the SSH agent

\n
eval "$(ssh-agent -s)"\nssh-add ~/.ssh/id_ed25519
\n\n

Step 3. Add the public key to GitHub

\n

Copy the contents of ~/.ssh/id_ed25519.pub:

\n
cat ~/.ssh/id_ed25519.pub
\n

Go to GitHub → Settings → SSH and GPG keys → New SSH key. Paste the key and save.

\n\n

Step 4. Configure Git to use SSH

\n

Now for the most important part: you need to make Go use SSH instead of HTTPS. To do this, edit the ~/.gitconfig file:

\n
[url "git@github.com:"]\n    insteadOf = https://github.com/
\n

This directive tells Git: "When you see https://github.com/ — use git@github.com: (SSH)".

\n\n

Step 5. Try again

\n
go get github.com/your-account/private-repository@latest
\n

If everything is configured correctly, the error will disappear. Go will use SSH for authentication, and the SSH agent will provide the key.

\n\n

Method 2: Using a Personal Access Token (PAT) — for CI/CD and scripts

\n\n

SSH is great for local development

Blogs

Book Recommendations