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
- Use the
nova keypair-addcommand 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.- To create a new keypair called mykey, use the command:
$nova keypair-add mykey - Alternatively, to use an existing public key stored in
~/.ssh/id_rsa.puband rename it to mykey, use the command:$nova keypair-add --pub_key ~/.ssh/id_rsa.pub mykey
- List all existing keypairs with the
nova keypair-listcommand:$nova keypair-list+---------+-------------------------------------------------+ | Name | Fingerprint | +---------+-------------------------------------------------+ | mykey | c3:d2:b5:d3:ec:4a:29:b0:22:32:6e:34:dd:91:f9:cf | +---------+-------------------------------------------------+ - Confirm that the uploaded keypair matches your local key by checking your key's fingerprint with the
ssh-keygencommand:$ssh-keygen -l -f ~/.ssh/id_rsa.pub2048 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.