• 请不要在回答技术问题时复制粘贴 AI 生成的内容
ethusdt
0.01D
V2EX  ›  程序员

GitHub 总是掉授权,电脑记不住 token

  •  
  •   ethusdt · Jul 9, 2023 · 2878 views
    This topic created in 1060 days ago, the information mentioned may be changed or developed.

    由于 GitHub 已经关闭了 https 的账号密码形式的验证,现在只能通过生成 token 的形式来当密码。

    When Git prompts you for your password, enter your personal access token.

    但电脑老是记不住这个 token ,下次 git fetch 还是会弹用户名和密码。

    我两台电脑,MBA 没问题,出问题的是新的 mac mini ,而且 mini 之前是没问题的,前几天刚出变成这样。

    在 keychain access 中查看 github 类型为 Internet password 的记录,在 Mac mini 上是没有的。

    所以不知道是什么情况。

    有没有遇到的小伙伴?应该怎么解决?

    9 replies    2023-07-10 12:18:38 +08:00
    GeruzoniAnsasu
        1
    GeruzoniAnsasu  
       Jul 9, 2023
    https://sheepblackish.medium.com/set-up-git-credentials-on-mac-os-with-private-key-github-access-token-8bf7b79e91d4

    不过我基本不用 HTTPS ,用 SSH

    SSH 协议用的是我的 gpg 公钥来验证,gpg suite ( gpg keychain )向我询问一次私钥保护密码后就一直 cache 了
    ethusdt
        2
    ethusdt  
    OP
       Jul 9, 2023
    @GeruzoniAnsasu 看来以后要都换成 ssh 了 没那么多问题了。
    codehz
        3
    codehz  
       Jul 9, 2023
    下载一个 github desktop 登录吧(
    或者用 github cli 也可以
    (会帮你配制好本地的 git 的
    Explr
        4
    Explr  
       Jul 9, 2023 via Android
    试试换个 credential helper ?比如 manager-core 或者 manager ?

    https://git-scm.com/docs/gitcredentials

    https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage
    thinkershare
        5
    thinkershare  
       Jul 9, 2023
    应该是系统的密钥凭证管理有问题,或者 github 没有在 mac mini 上正确使用凭证管理,如果你能够确保你的系统是安全的话,可用这样做, 这两种模式的缺点是别人通过 git remote 或者查看你的 git config 文件能够盗取你的凭证。
    git clone https://[email protected]/$user/$repository.git
    git clone https://oauth2:[email protected]/$user/$repository.git
    julyclyde
        6
    julyclyde  
       Jul 9, 2023
    如果你定位到是 keychain 的问题,你看看那个记录是否在 icloud chain 里?
    mohumohu
        7
    mohumohu  
       Jul 9, 2023
    Github Desktop 一键
    wxxxcxx
        8
    wxxxcxx  
       Jul 9, 2023
    装一个 github 的 cli 客户端,然后

    ```
    gh auth login
    ```

    然后 git 用 https 就行了,我一直这么操作的。
    blankmiss
        9
    blankmiss  
       Jul 10, 2023
    或者用 ssh 认证
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2747 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 15:41 · PVG 23:41 · LAX 08:41 · JFK 11:41
    ♥ Do have faith in what you're doing.