git-mirror icon indicating copy to clipboard operation
git-mirror copied to clipboard

Problem with enabled 2FA on local GitLab instance

Open hirnschmalz opened this issue 6 years ago • 7 comments

Hi there,

I've problems with (I guess) 2FA enabled accounts. The following error message occures while trying to push:

ERROR - Unable to sync repo https://github.com/TYPO3/TYPO3.CMS.git -> https://git.custom-domain.tld/mirror-test/TYPO3.CMS.git (Command "git" "push" "--mirror" "https://git.custom-domain.tld/mirror-test/TYPO3.CMS.git" failed with exit code: 128, Stderr: fatal: could not read Username for 'https://git.custom-domain.tld': terminal prompts disabled

Maybe the reason is the slightly different username/password handling with enabled 2FA?

I'm using the docker image.

hirnschmalz avatar Jul 27 '18 07:07 hirnschmalz

Have you tried using SSH instead of HTTP to push to your instance?

bachp avatar Jul 27 '18 09:07 bachp

Our local git instance does not allow SSH.

hirnschmalz avatar Jul 27 '18 09:07 hirnschmalz

Currently to only way to push to HTTPS is to include the credentials in the URL:

git-mirror -u https://user:[email protected]/

I haven't tried this tough. Let me know if this works.

bachp avatar Jul 27 '18 09:07 bachp

This does not work, since this is only used for fetching the repositories inside the group. As far as I can see the URL for pushing is fetched via the GitLab API.

For now I will add .gitconfig and a .git-credential file with the required information.

hirnschmalz avatar Jul 27 '18 09:07 hirnschmalz

If you get it working it would be nice if you could write a quick howto that can be included in the README.

bachp avatar Jul 27 '18 11:07 bachp

Hi @bachp ,

there are two things I had to do

So as far as I can see to make git-mirror working with GitLab 2FA enabled the docker image must respect two new Environment variables

  • one two tell that 2FA is enabled
  • if 2FA is enabled a username must be provided

With this Information it should be possible to make everything working even if 2FA with http only access.

Markus

hirnschmalz avatar Jul 28 '18 18:07 hirnschmalz

I need to give it some more tought how this could be improved.

One idea would be to set GIT_ASKPASS and write a small helper that provides the credentials to git from config or environment variables.

bachp avatar Jul 30 '18 21:07 bachp