1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/virt-adding-key-creating-vm-template.adoc
2025-11-18 16:29:25 +01:00

80 lines
2.6 KiB
Plaintext

// Module included in the following assemblies:
//
// * virt/virtual_machines/virt-accessing-vm-ssh.adoc
ifeval::["{context}" == "static-key"]
:static-key:
:title: Adding a key
endif::[]
ifeval::["{context}" == "dynamic-key"]
:dynamic-key:
:title: Enabling dynamic key injection
endif::[]
:_mod-docs-content-type: PROCEDURE
[id="virt-adding-key-creating-vm-template_{context}"]
= {title} when creating a VM from a template
ifdef::static-key[]
[role="_abstract"]
You can add a statically managed public SSH key when you create a virtual machine (VM) by using the {product-title} web console. The key is added to the VM as a cloud-init data source at first boot. This method does not affect cloud-init user data.
Optional: You can add a key to a project. Afterwards, this key is added automatically to VMs that you create in the project.
endif::[]
ifdef::dynamic-key[]
[role="_abstract"]
You can enable dynamic public SSH key injection when you create a virtual machine (VM) from a template by using the {product-title} web console. Then, you can update the key at runtime.
[NOTE]
====
Only {op-system-base-full} 9 supports dynamic key injection.
====
The key is added to the VM by the QEMU guest agent, which is installed with {op-system-base} 9.
endif::[]
.Prerequisites
* You generated an SSH key pair by running the `ssh-keygen` command.
.Procedure
. Navigate to *Virtualization* -> *Catalog* in the web console.
ifdef::dynamic-key[]
. Click the *Red Hat Enterprise Linux 9 VM* tile.
endif::[]
ifdef::static-key[]
. Click a template tile.
+
The guest operating system must support configuration from a cloud-init data source.
endif::[]
. Click *Customize VirtualMachine*.
. Click *Next*.
. Click the *Scripts* tab.
. If you have not already added a public SSH key to your project, click the edit icon beside *Authorized SSH key* and select one of the following options:
* *Use existing*: Select a secret from the secrets list.
* *Add new*:
.. Browse to the SSH key file or paste the file in the key field.
.. Enter the secret name.
.. Optional: Select *Automatically apply this key to any new VirtualMachine you create in this project*.
ifdef::dynamic-key[]
. Set *Dynamic SSH key injection* to on.
endif::[]
. Click *Save*.
. Click *Create VirtualMachine*.
+
The *VirtualMachine details* page displays the progress of the VM creation.
.Verification
* Click the *Scripts* tab on the *Configuration* tab.
+
The secret name is displayed in the *Authorized SSH key* section.
ifeval::["{context}" == "static-key"]
:!static-key:
endif::[]
ifeval::["{context}" == "dynamic-key"]
:!dynamic-key:
endif::[]