Skip to content

GitHub Client Requires Username to Clone Even Authenticated

Problems

I Installed the GitHub client and authenticated with https using gh auth login. But when I am trying to clone a repository, it prompt me to input username and password for github.com like the following,

Bash
root@vm:~# gh repo clone <repo>
Cloning into '<repo>'...
Username for 'https://github.com':

I can't understand why it needs input username.

Solution

From github cli repository issue list I found the solution https://github.com/cli/cli/issues/1326#issuecomment-732349626, that it needs to set authentication for git.

In my case, I need to set for https authentication like,

Bash
gh config set git_protocol https -h github.com
gh auth setup-git

If you use ssh, the you may need to set for ssh like,

Bash
gh config set git_protocol ssh -h github.com
gh ssh-key add ~/.ssh/<my-key>.pub