创建 ssh 密钥对以复制到其他地方,而不会弄乱我的个人 ssh 设置

创建 ssh 密钥对以复制到其他地方,而不会弄乱我的个人 ssh 设置

在我的 Mac 中,我已经有一个个人 RSA 密钥对,~/.ssh
我想在我的 Mac 中但为另一台计算机创建几个 RSA 密钥。所以我不想运行一些 ssh 命令并以某种方式替换我现有的密钥。
只需在自定义目录中为用户 A 和 B 创建一些密钥对,以便我可以将它们复制到我需要的位置,并确保我的个人 SSH 设置没有被替换/损坏。
我怎样才能安全地做到这一点?

答案1

使用-f旗帜

例如

% ssh-keygen -f /tmp/foobar
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /tmp/foobar.
Your public key has been saved in /tmp/foobar.pub.

答案2

只需使用ssh-keygen,当要求输入密钥对的名称时,请使用默认路径(以及可选的文件名)以外的其他名称。然后,您可以在指定的位置找到生成的密钥对。

相关内容