Transfer a file to an instance
Use the p0 file-transfer command to copy a local file to an AWS EC2 instance through P0's just-in-time File Transfer integration.
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 installed for the target AWS account.
The P0 CLI (see 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, runp0 ls ssh session destination.
Transfer a file
Run the p0 file-transfer command with the local file path and the destination instance ID:
p0 file-transfer <source> <destination>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:
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:
--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:
Confirms the source path points to a regular file before requesting access.
Requests just-in-time access to the staging bucket and the destination instance.
Uploads the file to a per-request prefix in your S3 bucket, using multipart upload with progress reporting.
Generates a short-lived presigned download URL.
Connects to the instance over SSH and downloads the file with
curl.Deletes the uploaded object from the bucket once the download succeeds.
Troubleshooting
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: set up and configure the integration.
SSH: the access layer File Transfer uses to reach instances.
Last updated