Modifying the Keypair Used by an Instance

You can replace the keypair used by an instance with another keypair.

This action only updates the public key reported by the metadata of the instance. To complete the replacement, you need to manually replace the old public key with the new public key in the ~/.ssh/authorized_keys file located inside the instance. You then need to restart the instance to apply the change.

You can also use this action to assign a keypair to an instance for which you did not initially specify a keypair.

To add a second keypair to an instance, paste the public key of the new keypair at the end of the ~/.ssh/authorized_keys file.

Modifying the Keypair Using Cockpit

The keypair of an instance can be modified in the instance attributes Modify Instance Attributes dialog box.
For more information, see Modifying an Instance Attribute.

Modifying the Keypair Using OSC CLI

To change your keypair, use the ModifyInstanceKeypair command following this syntax:

Request sample
$ osc-cli fcu ModifyInstanceKeypair \
    --InstanceId i-01234567 \
    --KeyName MyKeyPair

This command contains the following attributes that you need to specify:

  • InstanceId: The ID of the instance for which you want to modify the keypair.

  • KeyName: The name of the new keypair.

The keypair of the instance is modified.

Related Pages

Corresponding API Method