scp Command Builder

Build a correct scp (Secure Copy Protocol) command without confusing flag order or the capital--P gotcha. Choose upload or download direction, enter local and remote paths, set a port, identity file and recursive flag — the command assembles instantly with proper user@host:/path syntax.

How to use the scp Command Builder

Choose the transfer direction: Upload copies from your local machine to a remote server; Download copies from the remote to local. The scp argument order changes accordingly: scp [flags] src dest — the source always comes before the destination.

Enter the local path (a file or directory on your machine) and the remote path (the destination directory or file on the server). The remote path is prefixed with user@host: to form the full SCP address.

Port: scp uses -P (capital P) unlike ssh which uses -p. This is the most common scp mistake. Leave blank for the default port 22. Identity file (-i) specifies the private key to authenticate with. Recursive (-r) copies directories recursively — required when the source is a directory.

Paths with spaces should be quoted; the builder quotes remote paths automatically when they contain spaces. Always test that the remote path exists and you have write permission before running a large transfer.

About scp

scp (Secure Copy Protocol) transfers files between hosts using the SSH protocol for authentication and encryption. It works over the standard SSH port (22) and uses the same key-based or password authentication as SSH. Unlike FTP, scp encrypts both authentication credentials and file data in transit.

The syntax is scp [options] [[user@]host1:]file1 [[user@]host2:]file2. Either the source or the destination (or both) can be remote. A remote location uses user@host:/path syntax — the colon separates the host from the path. Local paths are plain filesystem paths with no colon prefix. You can also copy between two remote hosts (host-to-host) by specifying both source and destination in remote format, though this requires the source host to have SSH access to the destination.

scp's main limitation compared to rsync is that it always transfers the full file — there is no delta algorithm. For repeated transfers of large files that change incrementally, rsync is faster. scp is better for one-off transfers where simplicity matters. Also note: OpenSSH 9.0+ deprecated the legacy SCP protocol in favour of SFTP by default; the command still works but uses SFTP under the hood. Use sftp or rsync -e ssh for more control over large or resumable transfers.

Common use cases

  • Uploading build artifacts — copy a compiled binary or dist/ folder to a production server from a CI runner or developer machine.
  • Downloading logs — pull application or access logs from a remote server for local analysis without leaving a copy on an intermediary.
  • Bootstrapping a new server — copy configuration files, SSH keys or scripts to a fresh server before Ansible or Terraform can run.
  • Database backup retrieval — download a compressed database dump from a production server for local import or archiving.
  • Cross-host file transfers — move files between two remote servers without first downloading them locally, useful for migrations.

Frequently asked questions

Why does scp use -P (capital) while ssh uses -p (lowercase)?

This is a historical inconsistency in the OpenSSH toolset. The scp command predates consistent flag naming — its -p flag was already taken (it means "preserve file permissions"). When the port flag was added, capital -P was used instead. Remember: SCP uses -P for Port.

How do I copy an entire directory with scp?

Use the -r flag: scp -r ./localdir user@host:/remote/. This copies the directory and all its contents recursively. Without -r, scp will error if the source is a directory.

Is scp secure?

scp uses SSH for transport, so authentication and data are encrypted. The main risk is that the remote path must be provided correctly — scp does not sandbox itself and will follow symlinks on the remote. Use -r only to directories you trust. For untrusted remote servers, sftp with restricted subsystem is safer.

Why is scp slower than expected?

scp does not support transfer resumption or delta transfers. For large files, it encrypts and transfers the entire file even on retries. Consider rsync -avz -e ssh for repeated or large transfers, which only sends changed bytes and supports --partial for resume.

Can I scp using a different SSH config?

Yes: scp -F ~/.ssh/config_other uses a specific SSH config file. The host aliases, IdentityFile, Port and User directives from your ~/.ssh/config are also honoured by scp automatically for any host you have configured there.