ssh, aws, amazon linux 2,

How to set up SSH keys on Amazon Linux 2

Apr 11, 2022 · 1 min read · Post a comment

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.

Prerequisites

  • 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]"

Output:

Enter file in which to save the key (/home/username/.ssh/id_rsa):

To accept the default file location press Enter.

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 Enter.

Step 3. Verify the SSH key pair.

ls ~/.ssh/id_*

Output:

/home/username/.ssh/id_rsa    /home/username/.ssh/id_rsa.pub

Conclusion

Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.