---
title: "alpacon cp"
description: "Copy files between your local machine and remote servers with Alpacon CLI. Find remote path syntax, transfer flags, and examples for uploads and downloads."
---

> Full documentation index: https://docs.alpacax.com/llms.txt

# alpacon cp

Copy files between your local machine and remote servers.

## Usage

`alpacon cp SOURCE... DESTINATION [flags]`

## Key facts

- Remote paths use `[USER@]SERVER:/path`.
- Pass multiple sources before the destination.
- Use `--work-session` to select a session explicitly.

## Flags

| Flag | Type | Description | Default |
| --- | --- | --- | --- |
| `-g, --groupname` | `string` | Specify groupname | — |
| `-h, --help` | `bool` | help for cp | `false` |
| `-n, --no-overwrite` | `bool` | Do not overwrite existing files on the server | `false` |
| `-r, --recursive` | `bool` | Recursively copy directories | `false` |
| `-u, --username` | `string` | Specify username | — |
| `--work-session` | `string` | Attach this transfer to a work-session (overrides 'work-session use') | — |
| `--output` | `string` | Output format: table or json | `table` |

## Examples

Upload files to a remote server

```bash
alpacon cp /local/file1.txt /local/file2.txt my-server:/remote/path/
```

Upload or download a directory

```bash
alpacon cp -r /local/directory my-server:/remote/path/
alpacon cp -r my-server:/remote/directory /local/path/
```

Download a file from a remote server

```bash
alpacon cp my-server:/remote/file.txt /local/path/
```

Upload without overwriting existing files

```bash
alpacon cp --no-overwrite /local/file.txt my-server:/remote/path/
```

Specify username with SSH-like syntax

```bash
alpacon cp /local/file.txt admin@my-server:/remote/path/
alpacon cp -r admin@my-server:/var/log/ /local/logs/
```

Specify username with flag

```bash
alpacon cp -u admin /local/file.txt my-server:/remote/path/
```

Specify groupname

```bash
alpacon cp -g developers /local/file.txt my-server:/remote/path/
```

Attach the transfer to a specific work session

```bash
alpacon cp /local/file.txt my-server:/remote/path/ --work-session 11111111-2222-3333-4444-555555555555
```

## Details

Copy files between your local machine and a remote server. Supports SSH-like `user@host:path` syntax for specifying the username inline with the remote path.

Remote paths use the format `[USER@]SERVER:/path`.

To edit a single remote file in place instead of copying it back and forth, see [`alpacon edit`](/reference/cli/edit/).

## Work session requirement

When you sign in with browser login, `alpacon cp` requires an active [work session](/reference/cli/work-session/) that includes the `webftp` scope. Service-token authentication bypasses this requirement. The token still needs a server ACL entry allowing the target server and a file ACL entry allowing the path: `upload` to send a file, `download` to fetch it, and both (or `*`) for `edit`.

New personal API tokens cannot hold command-execution or file-transfer scopes. Existing tokens with those scopes keep working without a work session. Use a [service token](/use/iam/applications/service-tokens/) for automation and CI.

The session to attach is resolved from the `--work-session` flag, the `ALPACON_WORK_SESSION` environment variable, or the active session set with [`alpacon work-session use`](/reference/cli/work-session/use/)—in that order. When the gate denies a transfer, `cp` exits with code **3**; run with `--output json` to get a machine-readable diagnostic on stderr. See [Gate errors](/reference/cli/work-session/#gate-errors) for the error codes.

## Temporary directory requirement

When transferring multiple files at once or using the `-r` flag to transfer directories, the server compresses the target files into a ZIP archive before transfer. This archive is created in the server's system temporary directory (`/tmp` on Linux, `$TMPDIR` (falling back to `/tmp`) on macOS, `%TEMP%` on Windows).

On Linux servers where `/tmp` is mounted as a small `tmpfs`, large transfers may fail due to insufficient space. Ensure the server has enough temporary-directory space for the files being transferred.

Source: https://docs.alpacax.com/reference/cli/cp/
