alpacon cp

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.

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

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.

Options

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

Examples

Upload files to a remote server:

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

Upload or download a directory:

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:

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

Upload without overwriting existing files:

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

Specify username with SSH-like syntax:

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

Specify username with flag:

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

Specify groupname:

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

Attach the transfer to a specific work session:

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

Work session requirement

When you sign in with browser login, alpacon cp requires an active work session that includes the webftp scope. Token authentication (API token or service token) bypasses this requirement.

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—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 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.

Last updated: