How to configure additional SSH keys to your public cloud instance?

Overview

Only one SSH key can be set up when creating an instance for the initial connection. To allow other users to access your instance, additional keys can be added by configuring the authorized keys file.

In the previous article, the user generated a key on one server, used SSH copy id to paste the key on the second server. Then accessed the second server from the first server itself.

This guide explains how to configure additional SSH keys for connections to your instance.

Prerequisites

There are certain prerequisites that need to be met before you begin:

  • A Public Cloud Instance

  • Administrative access (root) to your instance via SSH

  • Access to Openstack Portal GUI

  • Second server to access the user account

Get Started

Step 1: Create a new public cloud instance

Click here to learn how to create a new public cloud instance.

Step 2: Generate a new SSH keypair to your instance

Enter the below command to generate a new key pair.

ssh-keygen

Step 3: You can now enter a file path or press enter to select default path (~/. ssh directory) to save your keypair.

Step 4: If you want to overwrite your existing key, enter Y. This process is not reversable.

Step 5: Your keypair’s fingerprint and random art image is now generated.

Step 6: Navigate to your .sh directory using the below command to access/view your keys:

cd .ssh

Step 7: Enter ls to view the files present in the above directory.

You will now see two key files listed in the directory

id_rsa – Private authorized key of the pair.

Id_rsa.pub - Public authorized key of the pair.

Step 8: Enter the below command to view and copy the id_rsa.pub file (public authorized key).

cat id_rsa.pub 

Step 9: Copy the public authorized key and paste it in the authorized_keys folder (home/user/.ssh/authorized_keys). Enter the below command to make changes in authorized_keys file.

nano authorized_keys 

Step 10: Enter the below command to access the private authorized key (id_rsa), copy and save the key in your local system (save the file in pem format).

Note: This will be the additional key that will be used to access this server.

cat id_rsa 

Step 11: Now open a new session and access the same server using the new additional key.

Last updated