Applies to: OpenSSH scp on Linux, macOS and Windows 10 and 11

scp copies files between computers over SSH. To copy a whole folder with its subfolders, add -r (recursive). We tested every example below between a Mac and a Ucartz VPS running AlmaLinux 9.

Upload a folder to a server

scp -r site user@server.example.com:/var/www/

This creates /var/www/site on the server, with all files and subfolders (hidden files included).

Download a folder from a server

scp -r user@server.example.com:/var/www/site ./site-backup

Where does the folder end up?

  • If the destination folder already exists, the copied folder goes inside it: scp -r site server:/tmp/dest gives /tmp/dest/site.
  • If it doesn’t exist, it is created with the new name: the contents of site end up directly in /tmp/dest.
  • To copy only the contents into an existing folder, use site/* (this skips hidden files at the top level): scp -r site/* server:/tmp/dest/

Useful options

scp -r -P 2222 site user@server:/var/www/    # SSH on another port (capital P)
scp -rp site user@server:/var/www/           # keep modification times and permissions
scp -r -i ~/.ssh/id_ed25519 site user@server:/var/www/   # use a specific key
scp -r -C site user@server:/var/www/         # compress while copying

Faster and resumable: rsync

scp -r copies everything every time. For large folders or repeated copies, rsync sends only what changed and can resume after a break:

rsync -avz --progress site/ user@server.example.com:/var/www/site/

More: rsync command examples.

Good to know

  • Since OpenSSH 9.0, scp uses the SFTP protocol underneath. If a very old server fails, add -O to use the legacy protocol.
  • “Permission denied” usually means you can’t write to the destination folder; copy to your home folder first.
  • Windows 10 and 11 include scp in PowerShell; WinSCP and FileZilla are graphical alternatives.

To leave some files out, see how to exclude files when copying with scp. For interactive uploads, see the put command in sftp.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket