我的个人访问令牌只缓存了有限的时间,密码会被贬值,因此我需要记住我的令牌吗?

My personal access token is only cached for a limited amount of time and passwords will be depreciated, am I therefore expected to memorize my token?

我喜欢通过命令行使用 Git 推送到我的 GitHub 存储库。 GitHub 最近一直在唠叨我改用个人访问令牌而不是密码。我今天和 switching my remote stuff to HTTPS, but the impression that I'm getting from their documentation is that my token will only be cached for a limited amount of time, on the order of 15 minutes, and that passwords will soon be depreciated 一起这样做了。这是否意味着我需要记住我的令牌,这是一长串我不能更改的字符?

不,你不需要记住它。在这种情况下,您可以使用两种解决方案。

首先,您可以使用凭证助手。有多种可供选择,通常您在 Windows 上使用 wincredmanager,在 macOS 上使用 osxkeychain,在 Linux 上使用 libsecret和 Unix(尽管如果您的发行版不提供它,您可能必须先编译它)。还有 store,它适用于任何系统,但以纯文本形式存储您的密码,这与其他加密存储密码不同。

您还可以使用带密钥的 SSH 代替 HTTPS 进行推送和拉取,这也是安全的,应该会继续工作。建议使用 Ed25519 密钥,您可以使用 ssh-keygen -t ed25519 创建该密钥,然后在 GitHub.

中上传到您的帐户