When you’re creating an instance, one key pair is added to your instance during launch, so that you can remotely connect using SSH. After you launched your instance, you can add extra SSH key pairs. This tutorial will explain how to add extra SSH key pairs to your instance.
Before you begin
Check if your system already has an SSH key pair at the default location by opening a shell, or command prompt on Windows, with the following command:
Windows Command Prompt:
If you see a file starting with ssh-rsa you already have an SSH key pair and you do not need to generate a new SSH key pair. If you do not see this file, you need to generate a new SSH key pair by using the following guide.
Adding SSH Key Pair:
- Copy the contents of your local public key “id_rsa.pub” including the beginning “ssh-rsa”:
Open the terminal and make an SSH connection with the (Ubuntu) instance.
Edit the “authorized_keys” on the instance and paste the contents of your clipboard below any other keys in that file:
Save with Ctrl+O and exit the file with Ctrl+X.
Exit the SSH session by using the command exit.
Try logging back into your instance to confirm it worked. If it did not ask for a password, then it worked.
You now have added an extra key pair to your instance so that multiple users can log in using SSH.