GitHub 不再支持密码验证解决方案: SSH 免密与 Token 登录配置 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
wsgzao
V2EX    程序员

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

  •  2
     
  •   wsgzao
    wsgzao 2021-08-15 17:16:27 +08:00 5496 次点击
    这是一个创建于 1586 天前的主题,其中的信息可能已经有所发展或是发生改变。

    今天提交代码,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 条回复    2021-08-17 09:05:29 +08:00
    icepie
        1
    icepie  
       2021-08-15 17:32:18 +08:00
    原来如此, 我以为是开了二步验证的问题
    lsvih
        2
    lsvih  
       2021-08-15 17:37:53 +08:00   2
    ```
    git remote set-url origin [email protected]:username/repo.git
    ```
    harwck
        3
    harwck  
       2021-08-15 17:39:59 +08:00
    Token 哪里麻烦了?就设置一下权限就好了。
    自从前几个月 GitHub 开始提醒的时候我就已经换到 Token 验证了。
    dingwen07
        4
    dingwen07  
       2021-08-15 18:09:30 +08:00
    一直都开着两步验证,这个变动应该没有影响
    xiangyuecn
        5
    xiangyuecn  
       2021-08-15 18:12:28 +08:00
    以前哪里填的密码,现在就在同样的位置填入 token 当做密码,大约 token == 密码
    dingwen07
        6
    dingwen07  
       2021-08-15 19:34:08 +08:00 via iPhone
    @xiangyuecn #5 密码可以用来生成 Token,但 Token 不能用于重置密码
    Mitt
        7
    Mitt  
       2021-08-15 19:47:17 +08:00
    本来其实直接用账户的密码的方式就不太合理的
    cweijan
        8
    cweijan  
       2021-08-15 19:48:04 +08:00
    现在把 token 当成密码就可以了, 比较麻烦的是需要清除掉以前保存的用户凭据
    fpure
        9
    fpure  
       2021-08-15 19:55:54 +08:00
    我想知道现在这个 token 是所有仓库共用一个 token 还是只能一个仓库一个 token ?
    Rheinmetal
        10
    Rheinmetal  
       2021-08-15 20:08:17 +08:00
    @fpure per repo 可以配 ssh key 吧
    yin1999
        11
    yin1999  
       2021-08-15 20:59:09 +08:00
    @fpure PAT(personal access token)是可以共用的
    beginor
        12
    beginor  
       2021-08-15 21:16:12 +08:00 via Android
    用 token 怎么试都不行,最后还是改用 ssh+key 了
    Trim21
        13
    Trim21  
       2021-08-16 07:55:31 +08:00 via Android
    最简单的办法是把远程地址换成
    https://username:[email protected]/username/repo.git
    Trim21
        14
    Trim21  
       2021-08-16 07:58:44 +08:00 via Android   1
    @Trim21 token 前面那个 username:也是可以省略掉的,直接 https://<token>@github.com/user/repo.git 也行
    istevenshen
        15
    istevenshen  
       2021-08-16 09:58:47 +08:00
    @Trim21 学习到了
    ysc3839
        16
    ysc3839  
       2021-08-16 10:41:55 +08:00
    个人觉得 token 并不麻烦,就只是把原来的密码换成 token,假如 token 麻烦的话原来用密码也一样麻烦。
    相反个人觉得 SSH 反而麻烦,比如配置代理不能简单地指定一个 http proxy 。
    Steaven
        17
    Steaven  
       2021-08-16 15:04:03 +08:00
    前天刚碰到这个问题,我还以为是因为我的库是私有库的原因。
    zliea
        18
    zliea  
      &nsp;2021-08-17 09:05:29 +08:00
    一直在用 ssh 推,一直也不知道 0.0
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     4815 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 27ms UTC 09:43 PVG 17:43 LAX 01:43 JFK 04:43
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86