Create and Manage SSH Keys

Modified on Mon, 30 Jan, 2023 at 11:21 AM

TABLE OF CONTENTS


On Linux


1. Check for an existing SSH key pair 


First, make sure that there are no other SSH keys on your system that may cause problems with 


generating the new key. Open up your favourite terminal application and type the following:


ls ~/.ssh


The above command will either give you a listing of all files within the directory, or it will 


output 'No such file or directory'. If the latter response is given, skip to step 3. 


Alternatively, if you would like to use an existing key-pair you may jump ahead to Step 4.


2. Backing up existing SSH keys


If you wish to backup your existing SSH Keys, execute the following commands: 


cd ~/.ssh 


mkdir key_backup 


cp id_rsa* key_backup 


rm id_rsa*

3. Generate a new SSH Key


To generate a new key pair type the following command in your terminal:


ssh-keygen


Follow the instructions to enter key files names (optional) and passphrase.


4. Add your keys to CloudAfrica


To get your key:


cat ~/.ssh/id_rsa.pub


Then, add your key into the 'SSH Keys' section of your CloudAfrica profile page, by clicking the 


'New SSH Key' button.


You can use keys added later when provisioning new server.


Alternatively you can add an ssh key to an existing server, from > CloudAfrica Dashboard, select


Servers > my.server > 'ssh keys' tab.


Be cautious not to add extra white spacing to it, as this will make it void.


On Windows

1. Prerequisites 

To generate an SSH keypair in windows download PuTTYgen from here. Note that you should download PuTTygen.exe (a RSA and DSA key generation utility). Thereafter, follow the steps seen below. 


2. Steps for Key Generation using PuTTYgen.exe

  • Open the PuTTYgen.exe.
  • Click the 'Generate' button in the lower right corner, making sure that you are generating an RSA type of key.
  • You’ll be asked to generate randomness by moving the mouse around, continue to do this until the load bar is full.
    • Click 'Save public key' and you’ll be prompted for a location on your hard drive to save the file. This key will be given out to the public, and it’s not necessary to keep it hidden. It is recommended that you keep your public key with your private key, so save it to a secure location.
    • Save your private key by following the following steps:  
      • Click the Conversions menu at the top.
      • Click Export OpenSSH key.
      • Choose a secure location to save the key (usually the location as the public key).
      • Give the key a name


3. Add your key to CloudAfrica


Copy the public key for pasting into Open SSH authorized_keys file that can be found in the textbox below Key from the PuTTygen.exe key generator into the 'SSH Keys' section of your CloudAfrica profile page, by clicking the 'New SSH Key' button .


NOTE: To open the public key file that you’ve saved, please do so in Wordpad (be careful not to use Notepad, as this will insert data, rendering it useless).


Noticed a discrepancy or a bug? > Let Us Know!

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article