// Module included in the following assemblies:
//
// * virt/managing_vms/ssh/virt-using-virtctl-ssh.adoc

:_mod-docs-content-type: PROCEDURE
[id="virt-using-virtctl-ssh-command_{context}"]
= Using the virtctl ssh command

[role="_abstract"]
You can use the `virtctl ssh` command to access a running virtual machine instance (VMI). The command accepts VM or VMI targets.

.Prerequisites

* You installed the `virtctl` command-line tool.
* You added a public SSH key to the VM.
* You have an SSH client installed.
* The environment where you installed the `virtctl` tool has the cluster permissions required to access the VM. For example, you ran `oc login` or you set the `KUBECONFIG` environment variable.

.Procedure

. Run the `virtctl ssh` command:
+
[source,terminal]
----
$ virtctl -n <namespace> ssh <username>@vm/<vm_name> -i <ssh_key>
----
+
You must specify the resource type (`vmi/` or `vm/`) before the VM name.
+
For example:
+
[source,terminal]
----
$ virtctl -n my-namespace ssh cloud-user@vm/example-vm -i my-key
----
