C.W.K.
Stream
Lesson 11 of 12 · published

SCP Basics

~15 min · scp, file-transfer, deprecated

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

The simplest file copy over SSH

scp looks like cp but the source or destination can be a remote machine via SSH. It's the simplest way to move a single file or a small directory across machines. Same key, same agent, same SSH path you've already set up — no new credentials, no new tools.

Where SCP falls short

SCP is great for one-off file copies. It's a poor fit for anything bigger:

  • No delta transfer — change a single byte in a 1 GB file, scp re-copies the whole file.
  • No resume — connection drops at 99%, start over.
  • No sync — can't reconcile two directories or skip what hasn't changed.
  • The protocol itself is deprecated — modern scp commands actually use SFTP under the hood.

For anything beyond a quick file grab, use rsync (Track 4). For an interactive file browser, use sftp.

Code

Common scp recipes·bash
# Local → remote
scp file.txt you_username@192.168.1.100:/home/you_username/

# Remote → local
scp you_username@192.168.1.100:/home/you_username/report.pdf ./

# Recursive — entire directory
scp -r ./project you_username@192.168.1.100:/home/you_username/

# Between two remote machines
scp you_username@server1:/file you_username@server2:/destination/

# Non-default port — note CAPITAL P (because scp is petty)
scp -P 2222 file.txt you_username@192.168.1.100:/home/you_username/

# Preserve modification times and permissions
scp -p file.txt you_username@host:/dest/

External links

Exercise

Create a small file: echo "hello from $(hostname)" > /tmp/hello.txt. scp it to another machine you have SSH access to. SSH in and confirm it arrived. scp it back to a different local path. Then try with -r on a small directory. Notice that scp respects your ~/.ssh/config host aliases (Track 3) — scp file.txt office:/tmp/ works once you have an alias.

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.