首页 > 解决方案 > 在共享计算机中管理私钥的最佳方法

问题描述

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

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

标签: gitsecurityprivate-key

解决方案


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


推荐阅读