gist icon indicating copy to clipboard operation
gist copied to clipboard

Show obvious error message if no working ssh key available

Open d9k opened this issue 7 years ago • 5 comments

% gist edit c17592d5ef054e634c7dbe48be0c186f
Cloning into 'c17592d5ef054e634c7dbe48be0c186f'...
Warning: Permanently added the RSA host key for IP address '192.30.253.119' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
1519185641.230 ERROR[gist] [Errno 2] No such file or directory: 'c17592d5ef054e634c7dbe48be0c186f

gist list works perfectly

I have access rights gist, notifications, repo for my token

d9k avatar Feb 21 '18 04:02 d9k

Since the error message states that the public key is denied, I suspect this is an issue of key management rather than with gist. Can you try

git clone [email protected]:d9k/c17592d5ef054e634c7dbe48be0c186f

see if that works.

jdowner avatar Feb 21 '18 10:02 jdowner

I created a new token for testing with the same permissions you had. I created a new VM for testing and installed gist. Like you, I was able to list the gists, but when I tried to edit a gist (which involves cloning the repo), I got the same error as you.

I created a new ssh key for the VM and added it to my github account. After that I was able to edit the gists.

The confusing thing here is that you can list all of your gists, but you cannot edit them. This seems inconsistent. The reason this occurs is that listing the gists goes through the github API and, therefore, access is determined by the token. But editing/cloning the gists is done via git, so it has nothing to do with the access token.

Originally, access tokens did not expose the different scopes that are now available. One of the scopes that is now available is to read the users public keys. This may provide a mechanism for detecting this kind of problem from within gist so that the user can, at least, be provided a more helpful message.

jdowner avatar Feb 21 '18 11:02 jdowner

@jdowner, thanks! I created ssh key, added it to my github account and now I can edit gists with your utility.

but manual git clone command you posted earlier doesn't work:

d9k@d9k-lap ~/temp % ssh-add ~/.ssh/d9k-github-lap             
Enter passphrase for /home/d9k/.ssh/d9k-github-lap: 
Identity added: /home/d9k/.ssh/d9k-github-lap (/home/d9k/.ssh/d9k-github-lap)

d9k@d9k-lap ~/temp % git clone [email protected]:d9k/c17592d5ef054e634c7dbe48be0c186f
Cloning into 'c17592d5ef054e634c7dbe48be0c186f'...
ERROR: Repository not found.
fatal: Could not read from remote repository.

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

What am I doing wrong?

d9k avatar Feb 21 '18 12:02 d9k

Apologies! That is my mistake. If you use,

git clone [email protected]:/c17592d5ef054e634c7dbe48be0c186f

it will work.

jdowner avatar Feb 21 '18 13:02 jdowner

@jdowner, cool, this works! Many thanks!

d9k avatar Feb 21 '18 13:02 d9k