While creating Amazon Linux 2 instance through the AWS console, there is a step that will provide you with the EC2 key pairs to connect to your instance. But if you need to set up some CI/CD or execute some scripts on a remote machine, then you’ll need to generate SSH keys on your Amazon Linux 2 instance. Let’s see how to do it quickly.
- Amazon Linux 2
Set Up SSH Keys on Amazon Linux 2
Step 1. Generate new 4096 bits SSH key pair.
ssh-keygen -t rsa -b 4096 -C "[email protected]"
Enter file in which to save the key (/home/username/.ssh/id_rsa):
To accept the default file location press
Step 2. Now, it will ask you for a passphrase.
Enter passphrase (empty for no passphrase):
It’s recommended to use a passphrase, but if you don’t want just press
Step 3. Verify the SSH key pair.
Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.