C.W.K.
Stream
Lesson 04 of 08 · published

scp vs rsync vs sftp

~8 min · scp, sftp, rsync

Level 0Window Tourist
0 XP0/95 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

Three tools, three cases

  • scp — old, simple, ssh-based copy. Good for one-shot single-file pushes/pulls.
  • rsync — covered last lesson. Smart sync; the everyday choice.
  • sftp — interactive ftp-like client over ssh. Good for browsing a remote tree without mounting it.

scp essentials

scp file.txt user@host:/path/         # local → remote
scp user@host:/path/file.txt .         # remote → local
scp -r dir/ user@host:/path/           # recursive
scp -P 2222 file.txt user@host:        # custom port (capital P!)

Note: capital -P for port (lowercase -p means preserve perms, opposite of ssh's -p).

scp deprecation note

OpenSSH has been moving to use SFTP under the hood for scp since 9.0; behavior is mostly the same but a few flags differ. For new scripts, prefer rsync or sftp. Old scp continues to work.

sftp interactive

sftp user@host
sftp> pwd
sftp> ls
sftp> cd /var/log
sftp> get app.log         # download
sftp> put local.txt       # upload
sftp> bye

When to use which

  • One file, both locations clear → scp is fine.
  • Multiple files, repeat operations, want resume + delta → rsync.
  • Need to browse the remote tree by hand, decide what to download → sftp.
  • Need a mounted directory → sshfs (brew install macfuse + sshfs, fragile but exists).

Code

Quick scp shapes·bash
scp ~/notes.md user@server:~/
scp user@server:/var/log/app.log .
# Use ssh_config aliases to simplify
scp big.tar work:/tmp/

External links

Exercise

Push a single file to a remote server with scp, then with sftp's put, then with rsync. Compare the output and the speed (rsync should win for non-trivial files because of -z compression).

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.