本文由 简悦 SimpRead 转码, 原文地址 www.cnblogs.com
用过 ssh 的朋友都知道,ssh key 的类型有很多种,比如 dsa、rsa、 ecdsa、ed25519 等,那这么多种类型,我们要如何选择呢?
说明
-
RSA,DSA,ECDSA,EdDSA 和 Ed25519 都用于数字签名,但只有 RSA 也可以用于加密。
-
RSA(Rivest–Shamir–Adleman)是最早的公钥密码系统之一,被广泛用于安全数据传输。它的安全性取决于整数分解,因此永远不需要安全的 RNG(随机数生成器)。与 DSA 相比,RSA 的签名验证速度更快,但生成速度较慢。
-
DSA(数字签名算法)是用于数字签名的联邦信息处理标准。它的安全性取决于离散的对数问题。与 RSA 相比,DSA 的签名生成速度更快,但验证速度较慢。如果使用错误的数字生成器,可能会破坏安全性。
-
ECDSA(椭圆曲线数字签名算法)是 DSA(数字签名算法)的椭圆曲线实现。椭圆曲线密码术能够以较小的密钥提供与 RSA 相对相同的安全级别。它还具有 DSA 对不良 RNG 敏感的缺点。
-
EdDSA(爱德华兹曲线数字签名算法)是一种使用基于扭曲爱德华兹曲线的 Schnorr 签名变体的数字签名方案。签名创建在 EdDSA 中是确定性的,其安全性是基于某些离散对数问题的难处理性,因此它比 DSA 和 ECDSA 更安全,后者要求每个签名都具有高质量的随机性。
-
Ed25519 是 EdDSA 签名方案,但使用 SHA-512 / 256 和 Curve25519;它是一条安全的椭圆形曲线,比 DSA,ECDSA 和 EdDSA 提供更好的安全性,并且具有更好的性能(人为注意)。
-
-
其他说明
-
RSA 密钥使用最广泛,因此似乎得到最好的支持。
-
ECDSA(在 OpenSSH v5.7 中引入)在计算上比 DSA 轻,但是除非您有一台处理能力非常低的机器,否则差异并不明显。
-
从 OpenSSH 7.0 开始,默认情况下 SSH 不再支持 DSA 密钥(ssh-dss)。根据 SSH 标准(RFC 4251 及更高版本),DSA 密钥可用于任何地方。
-
Ed25519 在 openSSH 6.5 中引入。
-
相关文章
OpenSSH supports several signing algorithms (for authentication keys) which can be divided in two groups depending on the mathematical properties they exploit: DSA and RSA, which rely on the practical difficulty of factoring the product of two large prime numbers,ECDSA and Ed25519, which rely on the elliptic curve discrete logarithm problem. (example)Elliptic curve cryptography (ECC) algorithms are a more recent addition to public key cryptosystems. One of their main advantages is their ability to provide the same level of security with smaller keys, which makes for less computationally intensive operations (i.e. faster key creation, encryption and decryption) and reduced storage and transmission requirements. OpenSSH 7.0 deprecated and disabled support for DSA keys due to discovered vulnerabilities, therefore the choice of cryptosystem lies within RSA or one of the two types of ECC. #RSA keys will give you the greatest portability, while #Ed25519 will give you the best security but requires recent versions of client & server[2]. #ECDSA is likely more compatible than Ed25519 (though still less than RSA), but suspicions exist about its security (see below).
-
结论
-
ssh key 的类型有四种,分别是 dsa、rsa、 ecdsa、ed25519。
-
根据数学特性,这四种类型又可以分为两大类,dsa/rsa 是一类,ecdsa/ed25519 是一类,后者算法更先进。
-
dsa 因为安全问题,已不再使用了。
-
ecdsa 因为政治原因和技术原因,也不推荐使用。
-
rsa 是目前兼容性最好的,应用最广泛的 key 类型,在用 ssh-keygen 工具生成 key 的时候,默认使用的也是这种类型。不过在生成 key 时,如果指定的 key size 太小的话,也是有安全问题的,推荐 key size 是 3072 或更大。
-
ed25519 是目前最安全、加解密速度最快的 key 类型,由于其数学特性,它的 key 的长度比 rsa 小很多,优先推荐使用。它目前唯一的问题就是兼容性,即在旧版本的 ssh 工具集中可能无法使用。不过据我目前测试,还没有发现此类问题。
总结
优先选择 ed25519,否则选择 rsa
Ref