求解:github开启了两步验证后git push使用https方式 验证权限失败

 红殿_真红王道哥哥 发布于 2022-10-25 08:44
hainuo@hainuo-ubuntu:/www/×××/.git$ git push 
Username for 'https://github.com': hainuo
Password for 'https://hainuo@github.com': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/hainuo/xi.git/'

我开启了github两步验证后应该如何解决?

由于windows下开发,编码老是自动转换成ansi或者gbk 实在搞不懂所以将电脑格式化撞了ubuntu在ubuntu下面没有githubforwindows方便的gui工具,只能够求助大家了

2 个回答
  • github开启二次验证后,提交时密码用个人设置里的Personal Access Token,而不是账号密码

    2022-10-26 14:44 回答
  • 已经有了解决方案
    参考方案是
    记住密码和用户名
    为命令行创建一个口令

    主要代码

    git config --global credential.helper store
    
    1. Go to your profile page.
    2. Applications menuIn the left sidebar, click Applications.
    3. Generate new token buttonClick Generate new token.
    4. Token description fieldGive your token a descriptive name
    5. Selecting token scopesSelect the scopes you wish to grant to this token. The default scopes allow you to interact with public and private repositories, user data, and gists.
    6. Generate token buttonClick Generate token.
    7. Newly created tokenCopy the token to your clipboard. For security reasons, after you navigate off this page, no one will be able to see the token again.

    然后需要做的就是在git push的时候

    Username for 'https://github.com': hainuo
    Password for 'https://hainuo@github.com': 
    

    这里的Password项目你将在github后台生成的access token 粘帖进去就行了

    至于文件保存在哪里?
    文件保存位置是/home/你使用的账户/
    会在这个目录生成两个文件
    .gitconfig
    .git-credentials
    之后你在linux终端里的操作就不会被验证程序打扰了。。

    2022-10-26 14:45 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有