在共享计算机中管理私钥的最佳方式

The best way to manage private key in a shared computer

我想知道一种在共享计算机中管理私钥的安全方法。 私钥用于 Git 到 pull/push/clone/ 到 "git://..." 的 Hub 身份验证。但是,PC 是与其他人共享的。其中一些可以是 root 用户,因此他们可以读取我的私钥。如果他们阅读了它,他们将拥有对我的存储库的访问权限。另外,我的 GitHub 密码太长记不住。它是由密码管理应用程序生成的,所以我不记得了。因此,我无法使用 Git URL "https://...".

输入密码

我想做的是以安全的方式在共享 PC 中使用 git。 你能给我一些建议或解决方案吗?

在 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 经理都提供带有密码的生成器。