解决 hexo 搭建的博客无法上传文章问题

有一天写完博客,准备上传时,执行 hexo d 命令后上传失败,并要求重新输入账号密码进行上传,输入密码后报了下面的错误:

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: Authentication failed for 'https://github.com/chunheli/chunheli.github.io.git/'
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: Spawn failed
    at ChildProcess. (/Users/lichunhe/myblog/node_modules/hexo-util/lib/spawn.js:52:19)
    at ChildProcess.emit (events.js:182:13)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)

查看错误信息中提供的链接,有如下的介绍:

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.

原来是 GitHub 更改了认证策略,后续认证方式改为 token 的形式,取消了账号密码的认证方式。

如何解决呢?方式如下:

For developers, if you are using a password to authenticate Git operations with GitHub.com today, you must begin using a personal access token over HTTPS (recommended) or SSH key by August 13, 2021, to avoid disruption. If you receive a warning that you are using an outdated third-party integration, you should update your client to the latest version.

我们需要按这个网址提供的教程创建一个个人 token,有个点要注意下,创建后要记得自己找个地方保存好,因为后续你就无法再次查看到这个 token 了。

接下来重新执行 hexo d 上传博客,输入账号,密码输入刚刚创建的 token 值,就可以正常上传了。

你可能感兴趣的:(解决 hexo 搭建的博客无法上传文章问题)