`gh cli` fails ` git@github.com: Permission denied (publickey)` but no problem with `gh desktop`

I'm a bit ashamed to admit that so far I used github desktop
and I'm now determined to try using gh cli I installed following the documentation

      sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
sudo apt-add-repository https://cli.github.com/packages
sudo apt update
sudo apt install gh

with apparent success

      $ which gh
/usr/bin/gh
$ gh --version
gh version 1.8.1 (2021-04-02)
https://github.com/cli/cli/releases/tag/v1.8.1

but to clone a public repo (for example flutter gallery) running gh repo clone flutter/gallery
I get the following error

      Cloning into 'gallery'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
exit status 128

(everithing worked "out-of-the-box" with gh-desktop)
what am I missing?

github discussion

2 ответа

Check first if you have the same issue using ssh directly:

      ssh -T git@github.com

If that is the case, check your ~/.ssh content, and make sure you have added and then tested an SSH key in order for said key to work from command line (since GitHub Desktop might manage its own key internally to the GitHub Desktop application)

поскольку аутентификация требуется даже для клонирования общедоступного репозитория с
запущенным gh auth login, устраняет проблему.
Я открыл проблему, предлагая clearer authentication error message

Другие вопросы по тегам