git - 在共享计算机中管理私钥的最佳方法
问题描述
我想知道一种在共享计算机中管理私钥的安全方法。私钥用于 GitHub 身份验证以拉/推/克隆/到“git://...”。但是,PC 是与其他人共享的。其中一些可以是 root 用户,因此他们可以读取我的私钥。如果他们阅读了它,他们将有权访问我的存储库。另外,我的 GitHub 密码太长记不住。它是由密码管理应用程序生成的,所以我不记得了。因此,我无法使用 Git URL“https://...”输入密码。
我想做的git
是以安全的方式在共享 PC 中使用。您能给我一些建议或解决方案吗?
解决方案
在 git 控制台中,您可以在生成密钥时为其添加密码。
基本上执行ssh-keygen
,它会询问您将密钥放在哪里以及您想要什么密码。
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/private/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): [PASSPHRASE]
Enter same passphrase again: [PASSPHRASE]
Your identification has been saved in /home/private/.ssh/id_rsa.
Your public key has been saved in /home/private/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:SPGTnzBrBfGCktlJm3iNRepVRS4XymcCrs3zq/g4g2g your_email@example.com
The key's randomart image is:
+---[RSA 4096]----+
| o.*..o+ |
| * & B o . |
| = @ @ B = |
| = * O B |
| + S o |
| . o |
| . . . |
| E . oo . |
| . o+o.. |
+----[SHA256]-----+
这是github的深度教程:
https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
此外,所有现代 git 管理器都提供带有密码的生成器。
推荐阅读
- javascript - 声明前后的JavaScript变量?
- regex - 正则表达式匹配应用程序数据包中的所有参数
- r - 生成随机稀疏矩阵
- asp.net - 通过网络传输日期的问题
- google-apps-script - 编写脚本以在数据输入时自动创建新的谷歌表
- android - FirebaseAuth因网络离线而登录失败如何处理?
- bash - 在 bash 脚本中使用传递的参数
- r - 将带 MM:SS.MS 的时间戳转换为不带日期 R 的 MM:SS.MS
- c# - 如何修复实例化 Excel.Application 对象时随机发生的 Excel.Application 错误
- c# - 如何从此 json 对象中获取值?