ssh key类型这么多,要如何选择呢?

2019-08-26 10:19:02 浏览数 (1)

用过ssh的朋友都知道,ssh key的类型有很多种,比如dsa、rsa、 ecdsa、ed25519等,那这么多种类型,我们要如何选择呢?

今天看到一篇相关文章,写的挺好的,在这里分享下。

在具体看这篇文章之前,我们先说结论:

1. ssh key的类型有四种,分别是dsa、rsa、 ecdsa、ed25519。

2. 根据数学特性,这四种类型又可以分为两大类,dsa/rsa是一类,ecdsa/ed25519是一类,后者算法更先进。

3. dsa因为安全问题,已不再使用了。

4. ecdsa因为政治原因和技术原因,也不推荐使用。

5. rsa是目前兼容性最好的,应用最广泛的key类型,在用ssh-keygen工具生成key的时候,默认使用的也是这种类型。不过在生成key时,如果指定的key size太小的话,也是有安全问题的,推荐key size是3072或更大。

6. ed25519是目前最安全、加解密速度最快的key类型,由于其数学特性,它的key的长度比rsa小很多,优先推荐使用。它目前唯一的问题就是兼容性,即在旧版本的ssh工具集中可能无法使用。不过据我目前测试,还没有发现此类问题。

再总结一下:

如果可以的话,优先选择ed25519,否则选择rsa。

代码语言:javascript复制
$ ssh-keygen -t ed25519

以下是原文:

代码语言:javascript复制
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).

更多相关介绍,请点击阅读原文。

完。

0 人点赞