ssh,

How to Set Up SSH Keys on Amazon Linux 2

Apr 11, 2022 · 1 min read · Post a comment
How to Set Up SSH Keys on Amazon Linux 2

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
  • sudo access

Set Up SSH Keys on Amazon Linux 2

Step 1. Generate new 4096 bits SSH key pair.

ssh-keygen -t rsa -b 4096 -C "your-email@site.com"

Example 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_*

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