If you want to create:
- An ED25519 key, read ED25519 SSH keys.
- An RSA key, read RSA SSH keys.
ED25519 SSH keys
The book Practical Cryptography With Go suggests that ED25519 keys are more secure and performant than RSA keys.
As OpenSSH 6.5 introduced ED25519 SSH keys in 2014, they should be available on any current operating system.
You can create and configure an ED25519 key with the following command:
ssh-keygen -t ed25519 -C "<comment>"
The -C
flag, with a quoted comment such as an email address, is an optional way to label your SSH keys.
RSA SSH keys
If you use RSA keys for SSH, the US National Institute of Standards and Technology recommends that you use a key size of at least 2048 bits. By default, the ssh-keygen
command creates an 1024-bit RSA key.
You can create and configure an RSA key with the following command, substituting if desired for the minimum recommended key size of 2048
:
ssh-keygen -t rsa -b 2048 -C "email@example.com"
The -C
flag, with a quoted comment such as an email address, is an optional way to label your SSH keys.
以.pub结尾的文件就是公钥