1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-07 00:48:01 +01:00
Files
openshift-docs/modules/virt-using-virtctl-port-forward-command.adoc

35 lines
1.3 KiB
Plaintext

// Module included in the following assemblies:
//
// * virt/virtual_machines/virt-accessing-vm-ssh.adoc
:_mod-docs-content-type: PROCEDURE
[id="virt-using-virtctl-port-forward-command_{context}"]
= Using the virtctl port-forward command
You can access a running virtual machine (VM) by using a local OpenSSH client and the `virtctl port-forward` command. You can use this method with Ansible to automate the configuration of VMs.
This method is recommended for low-traffic applications because port-forwarding traffic is sent over the control plane. This method is not recommended for high-traffic applications such as Rsync or Remote Desktop Protocol because it places a heavy burden on the API server.
.Prerequisites
* You have OpenSSH installed.
* You installed the `virtctl` command-line tool.
* The environment where you installed `virtctl` has the cluster permissions required to access the VM. For example, you ran `oc login` or you set the `KUBECONFIG` environment variable.
.Procedure
. Add the following text to the `~/.ssh/config` file on your client machine:
+
[source,terminal]
----
Host vm/*
ProxyCommand virtctl port-forward --stdio=true %h %p
----
. Connect to the VM by running the following command:
+
[source,terminal]
----
$ ssh <user>@vm/<vm_name>.<namespace>
----