【问题标题】:GitLab authentication failure with Github account使用 Github 帐户的 GitLab 身份验证失败
【发布时间】:2016-03-29 16:05:37
【问题描述】:

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

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

我做错了什么?

【问题讨论】:

  • 您确定您使用的是 ssh 网址吗? SSH URL 包含用户名,因此 git 不会要求它。
  • @MrTux 您的评论应该是 Nr。 1 个回答。为我工作!

标签: gitlab


【解决方案1】:

已于 2020 年 4 月 28 日下午 4:00(菲律宾标准时间)更新,以包括私人回购的范围。

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

  • 照常登录您的 GL 实例帐户。
  • 点击您的头像并选择设置。
  • 在用户设置侧边栏,点击访问令牌。
  • 在添加个人访问令牌部分,提供一个唯一的名称和可选的到期日期。
  • 仅选择 api 作为新访问令牌的范围。如果您在私人项目中工作,还包括 read_repository 和 write_repository 范围。
  • 点击创建个人访问令牌,让 GitLab 为您生成它。
  • 复制访问令牌。出于安全原因,您将无法再次看到它。 Instance Admins can help you create API keys, but they'll also see this once。

像对待密码一样对待您的访问令牌! 将下一个访问令牌的范围保持在较低水平,并且只与您信任的人共享。因为我在这里分享了示例令牌,所以现在任何使用它的尝试都会触发错误,因为我在更新答案之前将其撤消了。

然后,在使用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]

【讨论】:

    猜你喜欢
    • 2017-03-19
    • 1970-01-01
    • 1970-01-01
    • 2020-01-17
    • 1970-01-01
    • 1970-01-01
    • 2017-07-25
    • 1970-01-01
    • 2021-02-28
    相关资源
    最近更新 更多