Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't clone from GitHub #600

Closed
m-radzikowski opened this issue Jan 11, 2022 · 10 comments · Fixed by #609
Closed

Can't clone from GitHub #600

m-radzikowski opened this issue Jan 11, 2022 · 10 comments · Fixed by #609
Assignees

Comments

@m-radzikowski
Copy link

Describe the bug

I cannot clone neither a private or public repository from GitHub.

To Reproduce

Steps to reproduce the behavior:

  1. Go to Settings -> SSH keys -> Generate key (RSA) -> copy the public part to GitHub account (https://github.com/settings/keys)
  2. On main screen click +
  3. Provide Remote URL: [email protected]:m-radzikowski/myprivaterepo.git
  4. Click Clone
  5. Error window: Invalid remove, Clone failed

Expected behavior

Repo should be cloned.

Smartphone (please complete the following information):

  • Device: Redmi Note 10
  • OS: Android 11
  • App Version: 1.5.10

Additional context

I cannot clone any repo - I also tried this repo with URL: [email protected]:maks/mgit.git, got the same error.

The error does not tell much about what is actually wrong.

I have MFA enabled on the github account, but this shouldn't matter if I use SSH URL, right?

@PyCoder040
Copy link

Generate a personal access token in the developer settings on GitHub. Use your normal username with HTTPS access, but for the password, use the actual token. Works perfectly.

@maks
Copy link
Owner

maks commented Jan 11, 2022

@m-radzikowski given you raised #601 as well did you ty using a MGit generated ssh key pair for both? If so, please try generating a ssh key pair another way and see if you have the same error?

@m-radzikowski
Copy link
Author

@maks I did not open the other issue. But I have run:

ssh-keygen -t rsa -b 4096 -C "my@email"

(as in GitHub docs)

I added the public key to GitHub, copied the private to phone and added it in MGit. Now when I try to clone my repo, I'm getting error with a little bit more descriptive message:

Clone failed
[email protected]:m-radzikowski/myprivaterepo.git: invalid privatekey: [B@c1...

I'm pretty sure the key is OK.

One difference - with the key generated in MGit, when I went to https://github.com/settings/keys, I saw that the key was in fact used. With my own key, it has "never used" label.

@maks
Copy link
Owner

maks commented Jan 12, 2022

Ah yes sorry my mistake, I got that mixed up that you had filled that one as well.

Thank you for the very clear steps to produce the error, I'll have a look at it and see if I can see what's not working.

@dleeftink
Copy link

Generate a personal access token in the developer settings on GitHub. Use your normal username with HTTPS access, but for the password, use the actual token. Works perfectly.

This is my workaround also after the March 15th deprecation of ssh-rsa1 keys by GitHub. I edited the raw config file of an existing repo on my phone to point to url = https://github.com/username/repo... under [remote "origin"] and included name = username and email = [email protected] under [name].

The updated HTTPS url is not reflected on the home repo screen if you were using [email protected]:username/repo.git before, however MGit seems to recognise the updated connection method nonetheless.

@hilbert-ralf
Copy link

hilbert-ralf commented Mar 17, 2022

Thanks for the workaround @dleeftink . But how can i now clone a new repository? In my imagination the correct way to generate a new ssh key with MGit witch matches the github requirements and then check out. Am i wrong? For me it seems MGit seems not (yet) to be able to generate such keys, is that correct?
Also i tried to generate such a ed25519 key, like from github recommended, manually and added it to my MGit installation. unfortunatelly clone then fails with "invalid privatekey". I assume MGit is not yep able to handle such keys.

Btw, awesome to have such an app on android!

@dleeftink
Copy link

@hilbert-ralf, just tried to clone a repository from my own GitHub account which works with the above method. I don't think Personal Access Tokens grant access to repo's authored by someone else. If necessary, try and fork a third-party repo and clone the fork from MGit's homescreen.

Also make sure that the right privileges are set under Github Settings > Developer settings > Personal access tokens (e.g. repo, delete_repo and possibly user.

Finally, my steps in MGit:

  1. Click the + icon
  2. Enter the repo's https://... details
  3. Press clone => wait for credential warning
  4. Enter credentials:
    a. GitHub email as username
    b. Your personal access token string as password

Hope that works! Would be nice to see MGit working natively with the latest SSH keys.

@maks
Copy link
Owner

maks commented Mar 18, 2022

Yes sorry about this issue, I haven't had a chance to look into it properly. The main problem, which has come up many times before is that MGit uses the JGit library which in turn makes use Jsch library for SSH and Jsch is very old and not been updated in a very long time.
Per this conversation thread, newer versions of JGit have moved to using the apache Java library for SSH but MGit has been stuck on a likewise ancient version of JGit because newer versions of JGit started using a Java class library API that was not available on older versions of Android. There is #545 but as I mentioned there I was looking more at the option of moving to using libgit2 instead of newer versions of JGit but I just haven't yet had the time to look at that as yet.
Moving to a newer version of JGit and thus stopping support for older versions of Android may perhaps be a short term solution to this issue.

@hilbert-ralf
Copy link

@hilbert-ralf, just tried to clone a repository from my own GitHub account which works with the above method. I don't think Personal Access Tokens grant access to repo's authored by someone else. If necessary, try and fork a third-party repo and clone the fork from MGit's homescreen.

Also make sure that the right privileges are set under Github Settings > Developer settings > Personal access tokens (e.g. repo, delete_repo and possibly user.

Finally, my steps in MGit:

  1. Click the + icon
  2. Enter the repo's https://... details
  3. Press clone => wait for credential warning
  4. Enter credentials:
    a. GitHub email as username
    b. Your personal access token string as password

Hope that works! Would be nice to see MGit working natively with the latest SSH keys.

Thank you so much @dleeftink , that did the trick! Did not understand before that i actually have to use an access token instead of my password and no ssh et all.

Also thank you @maks for explaining the underlying issue. =)

From my side with that explanation put anythere present it would be okay to close the issue.

best regards.

@f-hollow
Copy link

f-hollow commented Sep 23, 2023

@dleeftink

Followed your steps and ran into the issue mentioned in #576. Then realized that instead of a fine-grained token I should use a classic personal access token as a password. Now everything works!

Thank you for providing the steps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants