Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
117
Help us understand the problem. What is going on with this article?
@kitoko552

GitHubに二段階認証を設定した後にGit操作できない時の解決策

この記事では非公開のOrganizationを使った例を載せていますが、個人のリポジトリでもほとんどやることは同じです。(おそらくステップ5が不要なくらい)

問題

GitHubに二段階認証を設定した後、普通にgit clone等のgit操作をしようとするとauthエラーで何もできない。

$ git clone https://github.com/private-organization/repository.git
Cloning into 'repository'...
Username for 'https://github.com': kitoko552
Password for 'https://kitoko552@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/private-organization/repository.git/'

httpsでなくsshに切り替えてもできない。

$ git clone git@github.com:private-organization/repository.git
Cloning into 'repository'...
Enter passphrase for key '/path/to/.ssh/id_rsa':
ERROR: The `private-organization' organization has enabled or enforced SAML SSO. To access
this repository, you must use the HTTPS remote with a personal access token
or SSH with an SSH key and passphrase
that has been whitelisted for this organization. Visit
https://help.github.com/articles/authenticating-to-a-github-organization-with-saml-single-sign-on/ for more information.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解決策

1. GitHubの自分のメニューからSettings>Developer settings>Personal access tokens

Settings Developer settings Personal access tokens
settings.png developer_settings.png personal_access_token.png

2. Generate new token

genereta_new_token.png

3. repoからgistまでを全てチェックしてGenerate token

new_personal_access_token.png

4. tokenをコピーしてどっかに保存(1回しか教えてくれないから注意)

5. 作ったtokenのSSOボタンをタップ -> ポップアップ内のprivate-organizationのAuthorize

SSOボタンをタップして...
sso.png

Authorize
authorize.png

6. httpsでgit clone

$ git clone https://github.com/private-organization/repository.git
Cloning into 'repository'...
Username for 'https://github.com': kitoko552
Password for 'https://kitoko552@github.com': {ここでGitHubのパスワードでなくtokenを入力する}
117
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
kitoko552
Software Engineer at CyberAgent, Inc. Flutter/Dart, iOS/Swift, Node.js, Kubernetes
standfm
stand.fmは多くの人が音声コンテンツを気軽に発信したり、お気に入りのチャンネルを簡単に見つけられるプラットフォームを目指しています。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
117
Help us understand the problem. What is going on with this article?