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

GitHub 不再支持密码验证解决方案: SSH 免密与 Token 登录配置

  •  2
     
  •   wsgzao ·
    wsgzao · Aug 15, 2021 · 6612 views
    This topic created in 1916 days ago, the information mentioned may be changed or developed.

    今天提交代码,push 到 GitHub 上,突然出现这个问题。

    remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.

    remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.

    fatal: unable to access 'https://github.com/wsgzao/wsgzao.github.io.git/': The requested URL returned error: 403

    官方的解释:https://github.blog/changelog/2021-08-12-git-password-authentication-is-shutting-down/

    As previously announced, starting on August 13, 2021, at 09:00 PST, we will no longer accept account passwords when authenticating Git operations on GitHub.com. Instead, token-based authentication (for example, personal access, OAuth, SSH Key, or GitHub App installation token) will be required for all authenticated Git operations.

    Please refer to this blog post for instructions on what you need to do to continue using git operations securely.

    Removal

    • August 13, 2021, at 09:00 PST

    大致意思是,密码验证于 2021 年 8 月 13 日不再支持,也就是今天 intellij 不能再用密码方式去提交代码。请用使用 personal access token 替代。

    这个去年年底就说了,https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/

    In July 2020, we announced our intent to require the use of token-based authentication (for example, a personal access, OAuth, or GitHub App installation token) for all authenticated Git operations. Beginning August 13, 2021, we will no longer accept account passwords when authenticating Git operations on GitHub.com.

    自己鼓捣了一遍 Token,烦人的很。还是觉得直接 ssh 的方式操作 git 就好(之前是 ssh 的源,也没有这个问题)。

    以下两种解决方案推荐使用 SSH 免密登录

    1. GitHub 配置 SSH 免密登录
    2. GitHub token
    # 登录 github 添加 SSH and GPG keys 公钥
    
    # 修改 git config
    vim wsgzao.github.io/.git/config
    
    [core]
            repositoryformatversion = 0
            filemode = false
            bare = false
            logallrefupdates = true
            symlinks = false
            ignorecase = true
            hideDotFiles = dotGitOnly
    [remote "origin"]
            url = https://github.com/wsgzao/wsgzao.github.io.git
            fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
            remote = origin
            merge = refs/heads/master
    
    # 替换 url = 
    
    [core]
            repositoryformatversion = 0
            filemode = false
            bare = false
            logallrefupdates = true
            symlinks = false
            ignorecase = true
            hideDotFiles = dotGitOnly
    [remote "origin"]
            url = [email protected]:wsgzao/wsgzao.github.io.git
            fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
            remote = origin
            merge = refs/heads/master
    
    

    Google 搜索到以下文章具体步骤非常详细,我就直接贴链接不再重复了

    https://www.cnblogs.com/zhoulujun/p/15141608.html

    18 replies  •  2021-08-17 09:05:29 +08:00
    icepie
    icepie
    Aug 15, 2021
    1
    原来如此, 我以为是开了二步验证的问题
    lsvih
    lsvih
    Aug 15, 2021❤️2
    2
    ```
    git remote set-url origin [email protected]:username/repo.git
    ```
    harwck
    harwck
    Aug 15, 2021
    3
    Token 哪里麻烦了?就设置一下权限就好了。
    自从前几个月 GitHub 开始提醒的时候我就已经换到 Token 验证了。
    dingwen07
    dingwen07
    Aug 15, 2021
    4
    一直都开着两步验证,这个变动应该没有影响
    xiangyuecn
    xiangyuecn
    Aug 15, 2021
    5
    以前哪里填的密码,现在就在同样的位置填入 token 当做密码,大约 token == 密码 🐶
    dingwen07
    dingwen07
    Aug 15, 2021 via iPhone
    6
    @xiangyuecn #5 密码可以用来生成 Token,但 Token 不能用于重置密码
    Mitt
    Mitt
    Aug 15, 2021
    7
    本来其实直接用账户的密码的方式就不太合理的
    cweijan
    cweijan
    Aug 15, 2021
    8
    现在把 token 当成密码就可以了, 比较麻烦的是需要清除掉以前保存的用户凭据
    fpure
    fpure
    Aug 15, 2021
    9
    我想知道现在这个 token 是所有仓库共用一个 token 还是只能一个仓库一个 token ?
    Rheinmetal
    Rheinmetal
    Aug 15, 2021
    10
    @fpure per repo 可以配 ssh key 吧
    yin1999
    yin1999
    Aug 15, 2021
    11
    @fpure PAT(personal access token)是可以共用的
    beginor
    beginor
    Aug 15, 2021 via Android
    12
    用 token 怎么试都不行,最后还是改用 ssh+key 了
    Trim21
    Trim21
    Aug 16, 2021 via Android
    13
    最简单的办法是把远程地址换成
    https://username:[email protected]/username/repo.git
    Trim21
    Trim21
    Aug 16, 2021 via Android❤️1
    14
    @Trim21 token 前面那个 username:也是可以省略掉的,直接 https://<token>@github.com/user/repo.git 也行
    shenwy
    shenwy
    Aug 16, 2021
    15
    @Trim21 学习到了
    ysc3839
    ysc3839
    Aug 16, 2021
    16
    个人觉得 token 并不麻烦,就只是把原来的密码换成 token,假如 token 麻烦的话原来用密码也一样麻烦。
    相反个人觉得 SSH 反而麻烦,比如配置代理不能简单地指定一个 http proxy 。
    Steaven
    Steaven
    Aug 16, 2021
    17
    前天刚碰到这个问题,我还以为是因为我的库是私有库的原因。
    zliea
    zliea
    Aug 17, 2021
    18
    一直在用 ssh 推,一直也不知道 0.0
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2110 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 94ms · UTC 01:51 · PVG 09:51 · LAX 17:51 · JFK 20:51
    ♥ Do have faith in what you're doing.