使用FreeOTP作为github的2FA验证App

发布时间 2023-10-28 00:33:14作者: Tamap

Github强制2FA验证-TOTP软件


前言

前两天登录github,发现强制2FA已经不能再拖了(QAQ),只能启用。

image

但是众所周知,短信没有+86,只能选择app

image
image

选择App后, 他会出现一个二维码, 我现在需要一个TOTP软件来扫这个二维码

软件选择

软件我选择了开源的 FreeOTP:Two-Factor Authentication
它有 安卓 IOS Linux 版本

引用介绍:

FreeOTP是一个使用一次性密码协议的双因素身份验证应用程序。通过扫描QR码可以轻松添加令牌。如果您需要生成QR码,请尝试我们的QR码生成器。
FreeOTP实现了开放标准:HOTP和TOTP。这意味着不需要任何专有服务器端组件:可以使用实现这些标准的任何服务器端组件。我们推荐使用FreeIPA。
FreeOTP由Red Hat赞助并正式发布。GitHub上的拉取请求在Apache License 2.0下是受欢迎的。请随时查看我们的隐私政策。

注: 原文: https://freeotp.github.io/ 翻译: 讯飞星火

p.s. 其实我选择它还有一个原因: 因为它的安装包只有6MB XD

下载

FreeOTP_icon

使用::以2.0.2(43)为例

设置密码

打开软件会提示要设置密码, 我总结一下其内容:

  1. 你添加的令牌可以备份和恢复
  2. 令牌的备份被密码加密
  3. 不能改密码: 所以千万别把密码忘了

想要看原文的话, 相关提示如下:

Android Keystore
FreeOTp tokens are now migrated into the AndroidKeystore! This results in increased security of tokensecrets, however key material is non-exportable.
Backup and restore functionality is now addedto ensure tokens can be recovered. You will beprompted to create a master password to setupencrypted token backups.

Android Keystore
FreeOTp令牌现在已迁移到AndroidKeystore!这导致令牌秘密的安全性增加,但密钥材料不可导出。
备份和恢复功能现已添加,以确保可以恢复令牌。您将被提示创建一个主密码来设置加密的令牌备份。

Backup and Restore
FreeOTp can participate in Android automatic backupand restore functionality. This <a href=https://support.google.com/android/answer/2819582?hl=en>Google link contains information on how toutilize this backup method.
Alternatively, an encrypted backup data file can beexported to external storage from within the App. Thetop toolbar menu now contains items labeled Backupand Restore' to utilize this manual backup method.

备份和恢复
FreeOTp可以参与Android的自动备份和恢复功能。这个<a href=https://support.google.com/android/answer/2819582?hl=en>Google链接包含了如何利用这种备份方法的信息。
另外,加密的备份数据文件可以从应用程序内部导出到外部存储。顶部工具栏菜单现在包含标记为“备份和恢复”的项目,以利用这种手动备份方法。

Token backups allow you to recover from data loss andeffortlessly transfer your tokens to a new device.
Backups are encrypted using the password provided below.
The security of your backups depends on a strong password.
The FreeOTp security model dictates this passwordCANNOT be changed at a later time. Please take this intoconsideration when choosing a password.

Token备份允许您从数据丢失中恢复,并轻松将您的令牌转移到新设备上。
备份使用以下提供的密码进行加密。
您的备份的安全性取决于一个强密码。
FreeOTp安全模型规定此密码在以后不能更改。在选择密码时,请考虑到这一点。

注: 以上翻译自讯飞星火

添加令牌

设置完密码后就很简单了: 点击软件右下角加号-扫码
扫描Github给出的二维码, 就完成了
要用的时候点击相应的令牌就可以用了

警告

你可能也注意到了, 扫码添加Github的令牌时, 软件会提示:

Token is unsafe!

The token you are attempting to add contains weak cryptographic parameters. Use of this token is stronly discouraged! Please alert your token provider.

令牌不安全!
您尝试添加的令牌包含弱加密参数。强烈建议您不要使用此令牌!请咨询您的令牌提供者。

如何会让你选择: [取消] [无论如何添加]
当然了这里肯定是选择添加的, 只不过我还是去搜了一下他们的issue

随后找到了这个 "Token is unsafe" message for GitHub token #334

按照他们的说法…… 是的,Github给的令牌确实不安全。他们表示这出现在Github上令人惊讶并且认为需要找他们报这个问题。
然后楼下有位Github PM回复了:称他们使用80位密钥是为了兼容Google Authenticator,因为Google Authenticator在很长一段时间里对于更长的密钥存在bug。原话后半段翻译过来说是:“目前尚不清楚他们是否已经修复了这个bug,因为该软件已经被废弃了很长时间——现在他们已经更新了支持同步的版本,也许他们也修复了这个问题。目前我们没有计划更新密钥长度。”

原句:

GitHub PM for Identity here. We use an 80 bit secret for compatibility with Google Authenticator, which had a bug for a very long time around longer secrets. It's unclear if they've since fixed it since it was abandonware for so long - now that they've updated it to support sync, maybe they fixed that too. Right now we have no plans to update the key length.

我的评价是:“该程序依靠BUG运行,勿动!” 哈哈开个玩笑,不过像这种兼容性问题,估计一时半会是改不了了。