Description of problem: If a static public key is injected into a VM after it has booted for the first time, the 'virtctl ssh' command does not work. This is, IMO, a serious problem because the SSH command is exposed in several places in the UI (VirtualMachines -> VirtualMachine details). However, if the user keeps the default Quick Create setting (start VM immediately), it is too late to add the SSH key. There is no warning in the QuickCreate modal to clear the "Start VM" checkbox if the user wants to be able to connect with virtctl SSH. I encountered the same issue when I created a NodePort service for SSH. Version-Release number of selected component (if applicable): How reproducible: Steps to Reproduce: 1. Create a RHEL VM. (I tested both RHEL 8 and 9.) 2. Do not clear the "Boot VM after creation" checkbox. 3. After the VM is created and boots, add a static public key (new or existing secret) to the VM. 4. Reboot the VM to apply the change. 5. Copy the 'virtctl ssh' command and try to run it from the command line. Actual results: Permission denied error. Expected results: SSH connection works. Additional info: Possible solution might be to disable the "Start VM" checkbox by default and add a tooltip saying that the key needs to be injected before first boot in order for SSH connection to work. I noticed a separate issue but am not sure whether it is worth filing a bug for it. I had a VM that I could connect to using 'virtctl ssh'. I deleted the secret from my namespace and removed it from the VM. After rebooting the VM, I was still able 'virtctl ssh' to connect to the VM.
The upstream docs say that static keys are injected at startup: "The virtual machine's access credential API allows statically injecting SSH public keys at startup time independently of the cloud-init user data by placing the SSH public key into a Kubernetes Secret." (https://kubevirt.io/user-guide/virtual_machines/accessing_virtual_machines/#ssh-access). However, this is not indicated in our downstream docs or the UI. If the 'virtctl ssh' command is exposed in the VM page, then it is too late for a user to use the feature because the VM is already running. Perhaps the dynamic SSH keys feature will resolve the issue, but only for VMs that support that feature.
Close the issue as it's been addressed by https://issues.redhat.com/browse/CNV-29233