Skip to content

How to add extra SSH Key Pairs to an Instance

Estimated time to read: 2 minutes

Introduction

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.

Prerequisites:

  • A running instance
  • SSH access
  • Key Pair

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:

cat ~/.ssh/id_rsa.pub
type %userprofile%\.ssh\id_rsa.pub

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:

  1. Copy the contents of your local public key “id_rsa.pub” including the beginning “ssh-rsa”:
    cat ~/.ssh/id_rsa.pub
    
  2. Open the terminal and make an SSH connection with the (Ubuntu) instance.
  3. Edit the “authorized_keys” on the instance and paste the contents of your clipboard below any other keys in that file:
    nano ~/.ssh/authorized_keys
    
  4. Save with Ctrl+O and exit the file with Ctrl+X.
  5. Exit the SSH session by using the command exit.
  6. Try logging back into your instance to confirm it worked. If it did not ask for a password, then it worked.

Conclusion

You now have added an extra key pair to your instance so that multiple users can log in using SSH.