1

I am trying to clone a repository from my GitHub account. I have logged into my account using:

> gh auth login --with-token < gh-token.txt

> gh --version
gh version 2.4.0+dfsg1 (2022-03-23 Ubuntu 2.4.0+dfsg1-2)
https://github.com/cli/cli/releases/latest

> gh auth status
github.com
  ✓ Logged in to github.com as mogur (/home/jonathon/.config/gh/hosts.yml)
  ✓ Git operations for github.com configured to use https protocol.
  ✓ Token: *******************

Everything seems fine until I try and clone a repository.

> gh repo clone mogur/alpha
Cloning into 'alpha'...
Username for 'https://github.com': mogur   
Password for 'https://mogur@github.com': **************
gh auth git-credential: "erase" operation not supported
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-
remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/mogur/alpha.git/'
exit status 128

I can't seem to find any documentation that would explain these results. I'm confused as to why I am being asked for a username and password.

I followed the instructions from "https://cli.github.com/manual/gh_repo_clone" and was expecting:

Cloning a repository:

~/Projects$ gh repo clone cli/cli
Cloning into 'cli'...
~/Projects$ cd cli
~/Projects/cli$

I also tried:

~/Projects/my-project$ gh repo clone https://github.com/cli/cli
Cloning into 'cli'...
remote: Enumerating objects: 99, done.
remote: Counting objects: 100% (99/99), done.
remote: Compressing objects: 100% (76/76), done.
remote: Total 21160 (delta 49), reused 35 (delta 18), pack-reused 21061
Receiving objects: 100% (21160/21160), 57.93 MiB | 10.82 MiB/s, done.
Resolving deltas: 100% (16051/16051), done.
Mogur
  • 11
  • 2

1 Answers1

1

First, check your gh version since this error message, reported in cli/cli issue 3891 is supposed to be fixed with PR 6805 for gh v2.21.2 in January 2023.

Second, the latest gh release 2.24.0 introduced:

Option to store gh access token in system encrypted storage

The gh auth login and gh auth refresh commands gained the new --secure-storage flag.
In this mode, the access token that GitHub CLI uses for GitHub API requests will now be stored in the system keyring instead of in the plain text config file.

To migrate as an existing GitHub CLI user, re-authenticate like so:

gh auth refresh --secure-storage -h github.com

Depending on your system, you could get an interactive prompt to allow the CLI tool to access the system keyring. The systems that are supported are:

  • Keychain on macOS
  • GNOME Keyring on Linux (Secret Service dbus interface)
  • Wincred on Windows

Your error message could be a side effect of this new (opt-in) option.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250