使用Github帐户GitLab身份验证失败

时间:2016-03-29 16:05:38

标签: gitlab

我最近使用我的Github帐户在gitlab上创建了一个项目。

但是当使用gitbash克隆项目时(我将当前的ssh-key添加到gitlab帐户),shell会提示输入用户名/密码,从github输入我的用户名和密码会导致身份验证失败。 (也是电子邮件/密码失败)

我做错了什么?

1 个答案:

答案 0 :(得分:1)

如果您尚未设置密码或受2FA保护,则需要通过GitLab帐户创建访问令牌。

  • 照常登录到您的GL实例帐户。
  • 点击您的个人资料图片,然后选择设置
  • 用户设置边栏中,单击访问令牌
  • 添加个人访问令牌部分,提供唯一的名称和有效期(可选)。
  • 仅选择api作为新访问令牌的范围。 An screenshot of creating a personal access token on a public GL instance.
  • 点击创建个人访问令牌,并让GitLab为您生成它。
  • 复制访问令牌。出于安全原因,您将无法再次看到它,除非some random admin access it through the API

enter image description here

  

像对待密码一样对待您的访问令牌!将下一个访问令牌的范围保持在较低水平,并仅与您信任的人共享。

然后,尝试使用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 "your-gl-account-email@example.com"


## 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://your-username@your-gl-instance-host.dev' [REDACTED]