Source: Dev.to | Jan 15, 2026 (UTC)
Managing secure access to your Amazon EC2 instances is critical, and one of the foundational steps is setting up an SSH key pair. AWS allows you to create and use your custom EC2 key pairs, providing flexibility for advanced security management. This guide outlines the steps to import a custom key pair into AWS.
Before you begin, ensure you have the following:
- Custom SSH Key Pair: Generate an SSH key pair using your preferred method or tool, such as OpenSSL, ssh-keygen, or a third-party tool.
- The private key will remain on your local machine for authentication.
- The public key will be imported into AWS.
- AWS CLI or AWS Management Console: This guide covers both methods for importing the key pair.
- IAM Permissions: Ensure your AWS user or role has the necessary permissions:
- ec2:ImportKeyPair
- ec2:DescribeKeyPairs
Step 1: Generate a Custom Key Pair (if not already created)
Using ssh-keygen
On a Linux, macOS, or Windows machine (with WSL or Git Bash):
ssh-keygen -t rsa -b 2048 -m PEM -C "[email protected]" -f my-custom-key
Enter fullscreen mode
Exit fullscreen mode


Залишити відповідь