GitHub二次验证带来的问题
GitHub开启二次验证后会导致博客提交的时候密码错误,无法提交至GitHub。具体提示如下:
INFO Deploying: git
INFO Clearing .deploy_git folder…
INFO Copying files from public folder…
INFO Copying files from extend dirs…
位于分支 master
无文件要提交,干净的工作区
Username for ‘https://github.com‘: fezl
Password for ‘https://fezl@github.com‘:
remote: Invalid username or password.
fatal: Authentication failed for ‘https://github.com/fezl/fezl.github.io.git/‘
FATAL Something’s wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: remote: Invalid username or password.
fatal: Authentication failed for ‘https://github.com/fezl/fezl.github.io.git/‘at ChildProcess.
(/home/leez/fezl.me/node_modules/hexo-util/lib/spawn.js:37:17)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:886:16)
at Socket.(internal/child_process.js:342:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:497:12)
FATAL remote: Invalid username or password.
fatal: Authentication failed for ‘https://github.com/fezl/fezl.github.io.git/‘Error: remote: Invalid username or password.
fatal: Authentication failed for ‘https://github.com/fezl/fezl.github.io.git/‘at ChildProcess.
(/home/leez/fezl.me/node_modules/hexo-util/lib/spawn.js:37:17)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:886:16)
at Socket.(internal/child_process.js:342:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:497:12)
这是由于在GitHub中开启了 Two-factor authentication(二次验证)导致。
两种解决办法:
一、关闭二次验证
不建议使用该方法,因为开启二次验证虽然在某些时候增加了一些麻烦,但是极大的提高了账户的安全性,我觉得这是值得的。
关闭步骤:
- 登录github.com
- Settings->Security
- 在 Two-factor authentication 栏下点击Edit
- 点击 Disable two-factor authentication
关闭二次验证后,hexo部署提交时使用的密码即为GitHub网站用户密码。
二、生成 Personal access tokens 令牌码,使用该码作为密码登录
生成步骤:
- 登录github.com
- Settings->Personal access tokens->Generate new token
- 给新令牌添加好备注
- 勾选该令牌权限,如图
- 点击 Generate token 生成令牌码
- 保存好生成的令牌码,该码即为1hexo d
后提示输入密码时使用的密码
为了安全起见,建议不要关闭二次验证。使用安全的令牌码进行登录提交。