1. 问题
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: unable to access 'https://github.com/***/***.git/': The requested URL returned error: 403
大概意思是:对密码身份验证的支持已于2021年8月13日移除。请改用个人访问令牌(personal access token)。
请参阅https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ 了解更多信息。
2. 官方说明
上面网站有官方说明和解决方法。
近年来,GitHub客户受益于GitHub.com的多项安全增强功能,例如双重身份验证、登录警报、验证设备、防止使用泄露的密码以及WebAuthn支持。这些功能使攻击者更难获取在多个网站上重复使用的密码并使用它来尝试访问您的GitHub帐户。尽管有这些改进,但由于历史原因,未启用双因素身份验证的客户仍然能够仅使用其 GitHub 用户名和密码继续对 Git 和 API 操作进行身份验证。
从2021年8月13日开始,我们在对Git操作进行身份验证时将
不再接受帐户密码
,并将要求使用基于令牌的身份验证
,例如个人访问令牌
(针对开发人员)或适用于GitHub.com上所有经过身份验证的Git操作的OAuth或GitHub应用程序安装令牌(针对集成商)。您也可以在您喜欢的地方继续使用SSH密钥
。
3. 使用SSH Key进行部署验证
参考之前的博客搭建文章,Hexo博客搭建(1):Mac端使用Hexo+GitHub Pages搭建免费个人博客
根据教程,生成SSH Key
,并在GitHub上添加SSH Key
,修改博客配置文件
中的deploy
节点即可。
将
deploy:
type: 'git'
repository: https://github.com/用户名/仓库名.git
branch: master
修改为
deploy:
type: 'git'
repository: git@github.com:用户名/仓库名.git
branch: master
因为https
方式适用于用户名密码验证,而git
的部署方式适用于SSH Key
验证。
4. 使用personal access token
4.1. 创建token
参考历史文章小书匠MD编辑器配置GitHub图床,创建个人访问令牌。
4.2. 修改deploy节点
deploy:
type: 'git'
repository: https://your_token@github.com/用户名/仓库名.git
branch: master