Create a Key Pair

Create a Key Pair

Key pairs are used in OpenStack for access authentication with an instance. Instead of logging on to your instance using a username and password, remote access to your instance requires a username and key pair. There are two methods for loading a key pair to OpenStack. First, you can create one through the OpenStack web interface and then download the file to your local host. Second, you can create one on your local machine first and then upload that key to OpenStack. Please make sure you follow the instructions for your method of choice. As long as the keys are loaded properly, there is no functional difference when using a key generate through either method.

Linux Host to OpenStack Method

Creating a Key Pair

Navigate to your ~/.ssh folder, which is a hidden directory inside of your home folder. Then type "ssh-keygen". This will prompt you to enter a filename for your key. The name you use doesn't matter but for this demonstration we will use "testKey". You will then be prompted to type a passphrase. Enter anything you like or leave the field empty if you don't want to use a passphrase. (It is recommend that you leave the passphrase blank, as it usually causes more problems having one then not having one.) This will create "testKey", which is the private key, and "testKey.pub", which is the public key. Make sure that you use the PUBLIC key, not the private key. Then open your "testKey.pub" file in a text editor and copy the key to your clipboard so you can use it on the OpenStack site.

Importing a Key Pair

Now that you have created a key pair, you need to import it to OpenStack. Go to the OpenStack site and navigate to the Key Pairs tab on the Access & Security page. In the top right hand corner, you will need to click the 'Import Key Pair' button. Fill in the information with a name for your key pair and the key that you have copied to your clipboard. After you click 'Import Key Pair' you key pair will be loaded for use with OpenStack.



OpenStack to Linux Host Method

Creating a Key Pair

First, navigate to the Access & Security page and click on the Key Pairs tab. Then, click the 'Create Key Pair' button located in the upper right-hand side of the page. Enter a name for your key pair, then click 'Create Key Pair'. A dialogue box will pop up asking you to open or save. Choose the save option. Once the file downloads, if the page doesn't auto-refresh, click again on the Access & Security page. Your key pair has been generated and it is now listed on the Key Pairs tab, but it won't work just yet.

Importing a Key Pair

Next, open a terminal and navigate to the folder where you saved the downloaded file. This is your private key. By default, this key has improper permissions and will not work properly with ssh. You can see these permissions by using the command:

ls -l

To remedy this, use the following command:

chmod 700 privatekey.ext

Where "privatekey.ext" is the name of your private key file. This disallows any other user to read/write/execute your private key and allows you to execute your private key. Finally, move your public key to your ~/.ssh folder. To move it, type the command:

mv privatekey.ext ~/.ssh

back to top

Previous: Security Groups
Next: Launch an Instance

OpenStack Main Page