Add or import keypairs

 

To add a key

You can generate a keypair or upload an existing public key.

  1. To generate a keypair, run the following command:

    $ nova keypair-add KEY_NAME > MY_KEY.pem

    The command generates a keypair named KEY_NAME, writes the private key to the MY_KEY.pem file, and registers the public key at the Nova database.

  2. To set the permissions of the MY_KEY.pem file, run the following command:

    $ chmod 600 MY_KEY.pem

    The command changes the permissions of the MY_KEY.pem file so that only you can read and write to it.

 

To import a key

  1. If you have already generated a keypair with the public key located at ~/.ssh/id_rsa.pub, run the following command to upload the public key:

    $ nova keypair-add --pub_key ~/.ssh/id_rsa.pub KEY_NAME

    The command registers the public key at the Nova database and names the keypair KEY_NAME.

  2. List keypairs to make sure that the uploaded keypair appears in the list:

    $ nova keypair-list