github密码失效&hexo d失败

news: GitHub防黑客新措施:弃用账密验证Git操作,改用token或SSH密钥,今晚0点执行

8月14日,github的密码验证失效,后续都使用双因素认证。

于是我在github代码推送的时候遇到这个问题。

6

1
2
3
4
5
6
7
8
9
10
11
12
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/Whale3070/Whale3070.github.io/': The requested URL returned error: 403
FATAL {
err: Error: Spawn failed
at ChildProcess.<anonymous> (/home/kali/Documents/Whale3070.github.io/node_modules/hexo-util/lib/spawn.js:51:21)
at ChildProcess.emit (events.js:314:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12) {
code: 128
}
} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html

开启双因素认证

https://docs.github.com/en/github/authenticating-to-github/securing-your-account-with-two-factor-authentication-2fa/configuring-two-factor-authentication

要下一个app,扫码获得一次性密码。
以后登录需要github密码+app上的六位数验证码

生成一个token

https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token
查看上文生成token以后,获得一串长度为40的字符串

在blog源码根目录下,vi _config.yml

1
2
3
4
5
6
# Deployment
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
type: git
repo: https://[这里复制你的token]@github.com/Whale3070[这是你的用户名]/Whale3070.github.io.git[这是你的仓库名,不要忘记要加上.git]
branch: main

即可正常hexo d更新blog