> For the complete documentation index, see [llms.txt](https://docs.p0.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.p0.dev/integrations/resource-integrations/file-transfer/transferring-files.md).

# Transfer a file to an instance

Use the `p0 file-transfer` command to copy a local file to an AWS EC2 instance. P0 requests just-in-time access, uploads the file to your staging bucket, and downloads it to the instance — all in a single command.

## Before you begin

Ensure you have the following:

* The [File Transfer integration](/integrations/resource-integrations/file-transfer.md) installed for the target AWS account.
* The [P0 CLI](/integrations/resource-integrations/ssh.md#install-the-p0-cli-package) installed, and an active login. Run `p0 login <your-p0-organization-name>` if you aren't logged in.
* The instance ID or name of your target EC2 instance. This is the same identifier you use for `p0 ssh`. To list available destinations, run `p0 ls ssh session destination`.

## Transfer a file

Run the `p0 file-transfer` command with the local file path and the destination instance ID:

```bash
p0 file-transfer <source> <destination>
```

| Argument      | Description                                                                                |
| ------------- | ------------------------------------------------------------------------------------------ |
| `source`      | Path to the local file to transfer. The path must point to a regular file.                 |
| `destination` | Instance ID or name of the target EC2 instance — the same identifier you use for `p0 ssh`. |

For example, to transfer a local `config.yaml` to instance `i-1234567890abcdef0`:

```bash
p0 file-transfer ./config.yaml i-1234567890abcdef0 --reason "Deploy updated config"
```

P0 prompts you through approval, uploads the file, and downloads it to your home directory on the instance, at `/home/<your-username>/config.yaml`.

## Options

Both flags are optional:

| Option     | Description                                                                  |
| ---------- | ---------------------------------------------------------------------------- |
| `--reason` | The reason you need access. Approvers see this when they review the request. |
| `--debug`  | Print debug information.                                                     |

## What happens during a transfer

When you run the command, P0:

1. Confirms the source path points to a regular file before requesting access.
2. Requests just-in-time access to the staging bucket and the destination instance.
3. Uploads the file to a per-request prefix in your S3 bucket, using multipart upload with progress reporting.
4. Generates a short-lived presigned download URL.
5. Connects to the instance over SSH and downloads the file with `curl`.
6. Deletes the uploaded object from the bucket once the download succeeds.

{% hint style="info" %}
Newly granted AWS permissions take a few seconds to propagate. P0 automatically retries the upload while the permission becomes active, so the first transfer to a bucket may take slightly longer.
{% endhint %}

## Troubleshooting

| Problem                             | Cause and resolution                                                                                                                                                |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Source file not found`             | The `source` path doesn't exist. Check the path and re-run the command.                                                                                             |
| `Source path is not a regular file` | The `source` points to a directory or special file. File Transfer moves a single regular file at a time.                                                            |
| `curl not found on <instance>`      | The destination instance doesn't have `curl` installed. Your file is already in the bucket — install `curl` on the instance, then re-run the command.               |
| The upload retries repeatedly       | This behavior is expected while a new AWS permission propagates. If retries continue to fail, run the command again with `--debug` to see the underlying AWS error. |

## Related

* [File Transfer integration](/integrations/resource-integrations/file-transfer.md) — set up and configure the integration.
* [SSH integration](/integrations/resource-integrations/ssh.md) — the access layer File Transfer uses to reach instances.
