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

FlagTypeDescriptionDefault
-g, --groupnamestringSpecify groupname—
-h, --helpboolhelp for cpfalse
-n, --no-overwriteboolDo not overwrite existing files on the serverfalse
-r, --recursiveboolRecursively copy directoriesfalse
-u, --usernamestringSpecify username—
--work-sessionstringAttach this transfer to a work-session (overrides ‘work-session use’)—
--outputstringOutput format: table or jsontable

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.

Work session requirement

When you sign in with browser login, alpacon cp requires an active 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 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—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).

Warning

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: