Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab authentication failure with Github account

Tags:

gitlab

I recently created a project on gitlab logged with my Github account.

But when cloning the project with gitbash (with my current ssh-key added to the gitlab account) the shell prompts for username/password, entering my username and password from github results in failure on authentication. (also email/password fails)

What I'm doing wrong?

like image 671
Marcos Vasconcelos Avatar asked Oct 30 '22 06:10

Marcos Vasconcelos


1 Answers

Updated as of 4/28/2020 4:00 PM (Philippine Standard Time) to include scopes for private repos.

You need to create an access token from your GitLab account if you not yet set up a password or if protected by 2FA.

  • Login to your GL instance account, as usual.
  • Click your profile picture and select Settings.
  • On User Settings sidebar, click Access tokens.
  • At the Add a personal access token section, give a unique name and, optionally expiration date.
  • Select api only as scope for your new access token. If you're working in private projects, also include read_repository and write_repository scopes. Creating a new access token in GitLab.com
  • Hit Create personal access token and let GitLab generate it for you.
  • Copy the access token. You'll be not able to see it again for security reasons. Instance Admins can help you create API keys, but they'll also see this once. enter image description here

Treat your access tokens like your passwords! Keep your scopes for next access tokens low and only share it with person/people you trust. Because I shared the example token here, any attempts to use it were now triggering errors because I revoked it before I update my answers.

Then, try logging in when using git push.

## Init the local repo
mkdir test-to-connect
cd test-to-connect
git init

## Add your user name and email to Git.
git config --global user.name "Your name"
git config --global user.email "[email protected]"


## Create a new private repo after pushing.
git remote set origin https://your-gl-instance-host.dev/your-username/your-new-project-slug

## Commit
git commit -m "Initial commit"

## Push to GitLab
git push origin
## Username for 'https://your-gl-instance-host.dev': your-username
## Password for 'https://[email protected]' [REDACTED]
like image 77
Andrei Jiroh Eugenio Halili Avatar answered Nov 08 '22 05:11

Andrei Jiroh Eugenio Halili