Use secure copy (SCP) from the command line to transfer files to
Google Distributed Cloud air-gapped appliance virtual machine (VM) instances.

## Before you begin

> [!IMPORTANT]
> **Important:** You *must already have access management enabled* to proceed. If you do not, follow the steps in [Guest environment](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/appliance/application/ao-user/vms/manage-the-os/guest-environment). By default, access management is enabled.

You need the following to use the SCP command-line tool to transfer files to VMs:

- You must manually manage your SSH keys.
- You must enable ingress on port 22 for your VM. See the [Enable IP addresses](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/appliance/application/ao-user/vms/connect-to-vm/ip-addresses) page for more information.

The SCP tool uses the same key files that you use to connect to your instances
using standard SSH.

> [!IMPORTANT]
> **Important:** If you haven't yet applied a public key to your VM instance, create an SSH key pair and add the public key to the VM following the instructions in [Linux (SSH)](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/appliance/application/ao-user/vms/connect-to-vm/connect-to-a-vm#api).

### Request permissions and access

To perform the tasks listed in this page, you must have the Project
VirtualMachine Admin role. Follow the steps to either
[verify](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/appliance/application/ao-user/vms/preparation#verify-user-access)
or have your Project IAM Admin
[assign](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/appliance/application/ao-user/vms/preparation#grant-user-access-vm-resources)
you the Project VirtualMachine Admin (`project-vm-admin`) role in the namespace
of the project where the VM resides.

## Transfer files to VMs

Locate the external IP address for the VM to which you want to send files using
the instructions on the [Enable IP addresses](https://docs.cloud.google.com/distributed-cloud/hosted/docs/latest/appliance/application/ao-user/vms/connect-to-vm/ip-addresses)
page.

Use the SCP tool to copy a file from your workstation to the home directory of
the target VM in the following example, which uses a private key at
`~/.ssh/my-ssh-key`:

    scp -i ~/.ssh/my-ssh-key LOCAL_FILE_PATH USERNAME@IP_ADDRESS:~

Use the following definitions for your variables.

| Variable | Definition |
|---|---|
| `LOCAL_FILE_PATH` | The name of the local file that you want to upload. |
| `USERNAME` | Your username. |
| `IP_ADDRESS` | The VM's external ingress IP address. |

## Transfer files from a VM

To copy files from a VM to your local workstation, reverse the source and
destination variables. The following example shows how to copy a file from your
VM to a path on your workstation:

    scp -i ~/.ssh/my-ssh-key USERNAME@IP_ADDRESS:REMOTE_FILE_PATH LOCAL_FILE_PATH

Use the following definitions for your variables.

| Variable | Definition |
|---|---|
| `USERNAME` | Your username. |
| `IP_ADDRESS` | The VM's external ingress IP address. |
| `REMOTE_FILE_PATH` | The name of the remote file that you want to download. |
| `LOCAL_FILE_PATH` | The location on your workstation to which you want to download the file. |