Thuta Learning
IntermediateHardwarebeginner

File Transfer (SCP/SFTP to Pi)

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Understand File Transfer (SCP/SFTP to Pi) without any of the intimidation
  • Be able to run the hardware wiring/code yourself
  • Apply this concept right away in a real project

Let's think about it this way for a moment

Once you've written a Python script using a code editor (VS Code) on your computer, you can send that file over to the Pi with scp (from the Linux tutorial) — upload it in the form scp local-file.py pi@raspberrypi.local:/home/pi/. It's even more convenient with the VS Code Remote-SSH extension — it connects VS Code directly to the Pi over SSH, letting you edit/save files on the Pi as if they were local files (no more manual scp needed).

Let's connect it to a real scenario

For a small project (a script or two), scp is quick and simple. As a project grows (many files, frequent changes), consider rsync -avz (from the Linux tutorial) or Git (not covered in the Linux tutorial, but a different, distinct project workflow). VS Code Remote-SSH, meanwhile, can dramatically boost your development workflow's productivity.

Let's look at it together

bash
# Upload a single file
scp led_blink.py pi@raspberrypi.local:/home/pi/

# Upload a whole project folder
scp -r ./my-project pi@raspberrypi.local:/home/pi/

# Sync (only changed files)
rsync -avz ./my-project/ pi@raspberrypi.local:/home/pi/my-project/
You should see
After running the scp command, you should be able to ssh in and see the file/folder has landed in the Pi's home folder.

5-minute try-it

Write a Python script (something like led_blink.py) on your computer and upload it to the Pi with scp (if you have a Pi).

A quick word of caution

If you run scp on public Wi-Fi (a café, say), remember the 'Network Security Basics' lesson from the Cybersecurity tutorial — scp/SSH is encrypted, but you still need to mind the trust level of the network as a whole.

Easy traps

  • Getting confused about where a file actually ends up because of a trailing slash (/) on the scp destination path — worth revisiting the Linux tutorial's scp/rsync lesson
  • Trying to run an scp command before SSH is connected — scp only works once the SSH connection itself is working

Now try it yourself

Write a Python script (something like led_blink.py) on your computer and upload it to the Pi with scp (if you have a Pi).

You'll know it worked when: After running the scp command, you should be able to ssh in and see the file/folder has landed in the Pi's home folder.

File Transfer (SCP/SFTP to Pi) | Thuta Learning