8.3. Creating or Adding a Keypair

The way in which Compute makes keys available is configurable. The Compute service can inject an SSH public key into an account on an instance, make it available via the metadata API, or make it available via a config drive, assuming the virtual machine image being used supports this.

Procedure 8.2. Creating or adding a Keypair

  1. Use the nova keypair-add command to add a keypair to the Compute service. This command can be used to either generate a new keypair, or to upload an existing public key.
    1. To create a new keypair called mykey, use the command:
      $ nova keypair-add mykey
    2. Alternatively, to use an existing public key stored in ~/.ssh/id_rsa.pub and rename it to mykey, use the command:
      $ nova keypair-add --pub_key ~/.ssh/id_rsa.pub mykey
  2. List all existing keypairs with the nova keypair-list command:
    $ nova keypair-list
    +---------+-------------------------------------------------+
    |  Name   |                      Fingerprint                |
    +---------+-------------------------------------------------+
    | mykey   | c3:d2:b5:d3:ec:4a:29:b0:22:32:6e:34:dd:91:f9:cf |
    +---------+-------------------------------------------------+
  3. Confirm that the uploaded keypair matches your local key by checking your key's fingerprint with the ssh-keygen command:
    $ ssh-keygen -l -f ~/.ssh/id_rsa.pub
    2048 c3:d2:b5:d3:ec:4a:29:b0:22:32:6e:34:dd:91:f9:cf /home/myaccount/.ssh/id_rsa.pub (RSA)
You have successfully added a keypair to the Compute service.