How to Securely Copy Files Over SSH (scp)
scp copies files between hosts over an encrypted SSH connection, using the same authentication as a normal SSH login.
Published September 30, 2026
scp copies files between hosts over SSH, encrypting the transfer. The syntax is scp source user@host:destination.
How it works
It uses your SSH keys and config. -r copies directories and -P sets the port (uppercase).
For large or repeated transfers, rsync is usually better.
Try it
scp backup.tar.gz ada@server:/var/backups/
backup.tar.gz 100% 12MB 8.1MB/s
Practical examples
Upload
scp file.txt user@host:/tmp/Download
scp user@host:/var/log/app.log ./Directory with a custom port
scp -P 2222 -r site/ user@host:/var/www/Between two remote hosts
scp user1@a:/file user2@b:/dest/Common mistakes
- Using -p lowercase for port (it preserves times).
- Overwriting remote files silently.
- Not quoting paths with spaces.
Key takeaways
- scp src user@host:dest.
- -r for folders, -P for port.
- Use rsync for big syncs.
FAQ
scp vs sftp?
sftp is interactive; scp is one-shot.
Is scp deprecated?
The old protocol is; OpenSSH now uses SFTP internally.