目录

一次性解决Github Enable two-factor authentication

一、背景

最近经常收到 github 的邮件:

Hey XXXX!


This is a reminder that we announced that we are requiring users contributing code on GitHub.com
 to enable two-factor authentication (2FA). 
You are receiving this notification because your account meets this criteria and will be required
 to enroll in 2FA by November 14th, 2024 at 00:00 (UTC).

Please see the below FAQ, or learn more about 2FA on GitHub Help.

大概意思是说限定时间内,github账号必须开启 两因素认证(2FA),否则将无法登陆

然后过期后你登陆github账号就会显示这样子:

二、什么是两因素认证(2FA)

2FA:多因素用户认证(Multi-Factor Authentication) ,现在很多大厂的服务其实都已经开启了,本质上就是一种强身份证验证,目的就是保障账号安全

三、解决

说明

从 github 的提示中,官方建议有三种方式开启 2FA

  • 方式一:Use an authenticator app

  • 方式二:browser extension

  • 方式三:一键短信验证

其中方式三短信验证,我的手机号码接收不到 github 的短信,所以用不了

(一)方式一:TOTP应用-Microsoft Authenticator

亲测可用

  • 手机应用商店搜索下载:Microsoft Authenticator

    /img/github-enable-2fa/0301.jpg
    TOTP应用

  • 打开 github 2FA 认证页面

    2FA · GitHub

    点击 enable 2FA now ,如下图

    /img/github-enable-2fa/0302.png
    2FAcode

手机打开刚才下载的 TOTP 应用 Microsoft Authenticator — 扫描 QR 码,然后会生成一个一次性密码代码

/img/github-enable-2fa/0303.png
一次性密码代码

将该动态码输入到gitthub认证界面 qr 码下的的输入框(Verify the code from the app)中 ,然后点击认证

/img/github-enable-2fa/0304.png
下载恢复码

最后点击 i have saved my recovery codes

进入步骤3,直接点击 done 即可完成 2FA 认证

(二)方式二:浏览器扩展

亲测可用

在浏览器安装 Authenticator 2FA client 拓展

不同浏览器的拓展的安装方式不同

        Microsoft Edge 加载项

        搜索:Authenticator

        这里测试使用的是:【Authenticator: 2FA Client】‪2,000,000+‬ 个用户

建议使用用户量比较多的拓展,才安全可靠

认证方式几乎和方式一 TOTP 应用一致,唯一不同的时是在扫描二维码的步骤,手机是直接APP扫码,浏览器拓展需要点击拓展应用上的扫码功能进行扫描,然后就会生成【一次性密码代码】

到这里就算结束了

总结

github 开启两因素认证(2FA)是对账号的一种强身份认证的安全措施,启动认证的方式有三种,推荐顺序如下:

  • 短信验证码(大陆用户手机号目前还接受不了,所以不考虑)

  • TOTP 应用(手机应用商店下载 Microsoft Authenticator,扫码生成一次性密码代码进行认证)(推荐)

  • 浏览器拓展(安装 Authenticator: 2FA Client 拓展,扫码生成一次性密码代码进行认证)

ß