8.7.2.3.3. Connect to a VM by using the virtctl ssh command
You can open an SSH session to a running virtual machine (VM) by using the virtctl ssh command. The command accepts a VM or a virtual machine instance (VMI) as the target.
Prerequisites
-
You installed the
virtctlcommand-line tool. - You added a public SSH key to the VM.
- You have an SSH client installed.
-
The environment where you installed the
virtctltool has the cluster permissions required to access the VM. For example, you ranoc loginor you set theKUBECONFIGenvironment variable.
Procedure
Run the
virtctl sshcommand:$ virtctl -n <namespace> ssh <username>@vm/<vm_name> -i <ssh_key>You must specify the resource type (
vmi/orvm/) before the VM name.For example:
$ virtctl -n my-namespace ssh cloud-user@vm/example-vm -i my-key