我怎么知道我的 ssh 密钥有多少位?

yai*_*chu 128 ssh

过去某个时候我已经为自己创建了一个 ssh 密钥。我不记得它是“多少位”。我怎么知道?

我想知道,因为我在 Nearfreespeech.net 上使用托管,他们的常见问题解答说:

我可以配置我的 ssh 连接以使用公钥吗?

...我们不会安装长度小于 1536 位的密钥 ...我们希望您使用长度至少为 2048 位的密钥,如果您要生成新密钥,建议长度为 4096 位。

Rai*_*tor 190

[palvarez@oizon ~]$ ssh-keygen -l -f ~/.ssh/id_rsa.pub
2048 2e:8c:fd:aa:9f:95:86:9e:b0:d2:a6:1a:7e:d3:3e:74 .ssh/id_rsa.pub (RSA)
Run Code Online (Sandbox Code Playgroud)

2048 位。

解释:

  -l          Show the fingerprint of the key file.
  -f filename Filename of the key file.
Run Code Online (Sandbox Code Playgroud)

  • 为什么要在有 SO 时阅读联机帮助页!?不……但实际上……有时重要的部分隐藏在对模糊标志等过于复杂的解释中。此外,我不认为 ssh-keygen 可用于检查已生成的文件。 (7认同)
  • 就像你的第二半部分一样,也许应该在打开联机帮助页之前阅读两半部分:-) (2认同)
  • 补充一点,将 -l 记住为“指纹/签名的长度”或将“-lf”都记住为“文件签名的长度”会有所帮助。希望能帮助别人,因为它帮助了我。 (2认同)

小智 8

您还可以看到密钥的视觉 ASCII 艺术表示。

ssh-keygen -l -v -f ~/.ssh/id_rsa.pub
3072 SHA256:3v8ZClFzsdN3ihY8U6TVWltcXheSz+DX40PLf2uSRwQ dobbs@snow (RSA)
+---[RSA 3072]----+
|             o*+*|
|           . E.=B|
|            X OoO|
|           . O.@+|
|        S . o B o|
|       . . o   * |
|        . o   + o|
|           o + =o|
|            o.*.o|
+----[SHA256]-----+
Run Code Online (Sandbox Code Playgroud)

3072 位。

解释:

     -l      Show fingerprint of specified public key file.
             If combined with -v, a visual ASCII art representation of the
             key is supplied with the fingerprint.

     -f filename
             Specifies the filename of the key file.

Run Code Online (Sandbox Code Playgroud)