保护为 AWS EC2 生成的私钥

Protecting private key generated for AWS EC2

据我所知,EC2 实例使用 public/private 密码术。 我的 ~/.ssh 本地文件夹中有一个包含私钥的 pem 文件。在存储 public 键的 ~/.ssh/authorized_keys 上的远程服务器上。 我说得对吗?

问题是,我如何保护我的私钥,即 pem 文件。

确保它有一个密码 - 绝不能是空白密码。切勿将其提交到代码存储库。切勿通过电子邮件发送或以其他方式披露。在不同的位置物理保护副本。

使用 PKCS#8 私钥格式。 From Improving the security of your SSH private key files

If you already have a strong passphrase on your SSH private key, then converting it from the traditional private key format to PKCS#8 is roughly comparable to adding two extra keystrokes to your passphrase, for free. And if you have a weak passphrase, you can take your private key protection from “easily breakable” to “slightly harder to break”.