LightAtom

scp Command: Copy Files over SSH

scp copies files securely between your Mac and another machine using SSH. Here's the syntax for every direction, folders, ports and keys.

scp report.pdf jane@server:/home/jane/

Upload a file to the server.

beginner5 minNeeds: SSH access to the other machine

When to use it

Use scp for quick one-off copies over SSH. For large or repeated transfers, rsync is better because it resumes and copies only what changed.

Steps

  1. Upload a file

    Source first, destination second. The remote side is user@host:path.
    scp notes.txt jane@203.0.113.10:~/
  2. Download a file

    Swap the order.
    scp jane@203.0.113.10:~/backup.tar.gz .
  3. Copy a folder

    -r copies recursively.
    scp -r ./site jane@203.0.113.10:/var/www/
  4. Use a port or a key

    Note the capital -P for the port (ssh uses lowercase -p).
    scp -P 2222 -i ~/.ssh/work_ed25519 file.zip jane@host:/tmp/

Output explained

scp shows one progress line per file:

backup.tar.gz                                 100%  148MB  42.3MB/s   00:03

Since OpenSSH 9.0, scp uses the SFTP protocol under the hood. Paths with spaces need quoting once, like '~/My Files/'. The old protocol is available with -O for servers without SFTP.

Options and variations

FlagMeaningExample
-rCopy folders recursivelyscp -r dir host:/tmp/
-P PORTSSH port (capital P)scp -P 2222 f host:
-i KEYIdentity filescp -i key f host:
-pPreserve times and modesscp -p f host:
-CCompress during transferscp -C big.log host:
-OUse the legacy SCP protocolscp -O f oldhost:

Common errors

ErrorCauseFix
No such file or directoryWrong path on either sideCheck the remote path with ssh host ls PATH.
Permission deniedNo write access to the destination folderCopy to your home directory first.
subsystem request failedServer has no SFTP subsystemAdd -O for the legacy protocol.

Do it in the app

LightAtom's connections view shows the SSH connection's live upload or download rate while scp runs.

Frequently asked questions

How do I copy a file from a server to my Mac?

scp user@host:/path/to/file ~/Downloads/ copies it into your Downloads folder.

Is scp deprecated?

The old SCP protocol is, but the scp command remains; since OpenSSH 9.0 it uses SFTP underneath. For big or repeated transfers, rsync -avz is better.

Why does scp use -P and ssh -p?

scp's -p was already taken by “preserve times and modes”, so the port option is a capital -P.

LightAtom team

The people who build LightAtom, a network monitor for macOS.