Overview
An SSH key pair is a secure authentication method for instance login, distinct from username-password authentication. This method is supported exclusively for Linux instances.
An SSH key pair uses asymmetric encryption and, by default, is generated by using RSA 2048-bit encryption. The key pair consists of a public key and a private key. A data encryptor uses the specified encryption algorithm and public key to encrypt plaintext, producing unreadable ciphertext. A data decryptor decrypts the ciphertext by using the corresponding private key (following the same encryption algorithm) to retrieve the original plaintext.
SSH advantages
The following items describe the advantages of using an SSH key pair to log in to an instance:
- Higher security: SSH key pairs use an asymmetric encryption algorithm. Only users who possess the private key can log in to the instance, which greatly enhances security.
- Password-free login: When you log in to an instance by using an SSH key pair, you do not need to enter a password, eliminating the risk of password cracking or theft.
- Convenience: A single SSH key pair can be used across multiple ECS instances, simplifying the management and access of multiple instances.
In general, compared with passwords, SSH key pairs provide a more secure and convenient method for logging in to instances. This method is ideal for scenarios where frequent instance logins are required or high security requirements must be met.
Limits
- Currently, ECS allows you to create only 2048-bit RSA key pairs.
- An account can have up to 500 key pairs in a region.
- Key pair names must be unique within the same account.
- You can associate a Linux instance with only one key pair in the ECS console. If you want to use multiple key pairs to log in to the same instance, you can modify the ~/.ssh/authorized_keys file within the instance to add multiple key pairs.
- You can associate or disassociate a key pair with up to 50 instances at the same time. However, there is no limit on the maximum number of instances that a single key pair can be associated with or disassociated from.
Usage notes
After you create an SSH key pair, the platform saves the public key of the SSH key pair. In Linux instances, the public key is stored in the ~/.ssh/authorized_keys file. However, you need to download and securely store the private key. You have only one opportunity to download the private key. The ECS console does not retain your private key. Make sure that the private key is properly safeguarded.
Operation guide
To log in to a Linux instance by using an SSH key pair, you need to first have a key pair. You can either specify the key pair when you create the instance or associate the key pair with the instance after the instance is created. Then, you can use the downloaded private key to log in to the instance.
FAQs