简体   繁体   中英

`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

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)

as authentication is required even to clone a public repository
running gh auth login fixes the issue
I've open an issue proposing a clearer authentication error message

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM