VOOZH about

URL: https://thenewstack.io/linux-lesson-copy-files-over-your-network-with-scp/

⇱ Linux Lesson: Copy Files Over Your Network with scp - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2020-07-03 08:07:08
Linux Lesson: Copy Files Over Your Network with scp
tutorial,
Edge Computing / Linux / Security

Linux Lesson: Copy Files Over Your Network with scp

How to use the Linux scp command to copy files from one machine to another on a local network using scp. It works great for the occasional single or handful of files.
Jul 3rd, 2020 8:07am by drtorq
👁 Featued image for: Linux Lesson: Copy Files Over Your Network with scp
Feature image by NeONBRAND on Unsplash.

I occasionally need to copy files between computers on my local network. It might be sound files for my robotic skull’s voice (on a Raspberry Pi), screenshot graphics captured for a tech article or any number of text configuration files. Since all my machines are Linux based, the easiest way to do it is with the scp command. scp stands for secure copy.

scp is part of the SSH family of remote network access services, native to Linux/Unix operating systems. If ssh is installed, you’ll probably already have scp as well. We discussed working with ssh in a recent TNS article. To use scp you simply need to have an operational ssh server on your remote machine and an ssh client running on the machine you are using, such as your Linux notebook.

scp on the open internet works fine, since ssh works there too, considering the above-mentioned requirements. I used to scp files from my Linux notebook up to my GoDaddy web site. Even though scp is hardened and encrypted be sure to practice appropriate security measures when venturing past the safety of your firewalled local-area network.

Today, we’ll look at using scp to copy files from one machine to another on a local network.

Setup and Usage

Using scp requires an ssh server on one end and an ssh client on the other end. Many of my Raspberry Pi-based projects have the ssh server set up for automatic operation after boot-up. That way, I only need an ssh client on my Linux notebook when I want to transfer some files.

I normally don’t run the ssh server on my everyday ASUS Linux notebook because it takes up computing resources and I don’t want anybody to be able to ssh into my machine. The ssh-client software is installed and I usually connect to other machines FROM the notebook.

After making sure the ssh server is running on your remote machine, you should also note its IP address. You’ll need that over on your local machine to connect using scp. Use the ifconfig command on the remote machine to get the IP address. If the remote machine is on wifi use the IP address for the wlan0 interface. A wired connection will have an IP address for the eth0 interface, which likely has a faster transfer speed. You can also use the ip command with the a option.

pi@raspberrypi: ifconfig

Here’s what the ifconfig command returns on one of my Raspberry Pi projects.

👁 Image

Finding the IP address using ifconfig on the Raspberry Pi

If you need to load the ssh client (scp included) on your local (my Linux notebook) machine use apt-get at the command line.

rob@rob-N80Vm:~$ sudo apt-get install ssh-client

Once the ssh client software is installed you can use the scp command to connect and transfer files to/from the remote machine (the Raspberry Pi running the ssh server).

The basic form of the command isscp, the source file name, then the destination file name. Here is an example.

rob@rob-N80Vm:~$ scp robnet.htm pi@192.168.1.101:/home/pi/robnet.htm

👁 Image

Using scp to copy an HTML text file from the Linux notebook to the Raspberry Pi.

In this case, robnet.htm is a local HTML file I use for my home page and the remainder is the fully qualified file name on the destination Raspberry Pi.

Notice the destination used includes a user name, pi and the IP address of the destination machine. Notice I’m using the eth0 or “wired” connection. I also used the pathname with directories explicitly spelled out. Enter the password for the user (in this case pi) when prompted.

You can use the full pathname in the source reference if you like. Since I frequently copy several files at a time, it usually makes sense to just cd over to the source directory and then not include it in the command. scp will look for the source file in your current directory. If you get a “can’t find the file” error make sure you are in the right directory and that everything is spelled correctly. Using command line history and cutting/pasting commands helps tremendously with your typing accuracy and speed of use.

Copying from the remote machine to your local notebook is just as easy. Simply flip the source and destination references.

rob@rob-N80Vm:~$ scp pi@192.168.1.101:/home/pi/robnet.htm robnet.htm

Keep in mind that scp overwrites files during the process. You won’t get a warning, so be careful. This is influenced by local file permissions. For example, if the local robnet.htm is read-only it won’t be overwritten and will return a “permission denied” warning. The bottom line is to always stay focused and deliberate in your actions when working on the command line.

Additional scp Odds and Ends

You can also copy files using wildcards such as the * symbol. At the command line, the * symbol means match anything.

Say I have a small collection of files in the pitemp directory on my Linux notebook. I want to copy that collection over to the temp directory on a Raspberry Pi project. I could change directory to pitemp on the notebook and then do the scp to the Pi.

rob@rob-N80Vm:~$ cd
rob@rob-N80Vm:~$ cd pitemp
rob@rob-N80Vm:~/pitemp$ scp * pi@192.168.1.101:/home/pi/temp

👁 Image

Using scp to copy a set of files with the * wildcard.

Notice the error saying that pi-subdir is not a file. It is, in fact, a directory with some files inside. In this case, it isn’t included in the copy. We may only want to copy the files and not the files plus any lower-level directories.

For copying files, including any sub-directories, from one machine to another we use the -r command line option. Here we’ll refer to the files in the aforementioned pitemp directory on my Linux notebook.

rob@rob-N80Vm:~$ cd
rob@rob-N80Vm:~$ cd pitemp
rob@rob-N80Vm:~$ scp -r * pi@192.168.1.101:/home/pi/temp

👁 Image

Using scp to copy files and directories.

👁 Image

Results of the scp -r option copy on the Raspberry Pi.

Wrap up

We’ve seen how to copy files from one machine to another on a local network using scp. It works great for the occasional single or handful of files. Once you get beyond a dozen or so at a time or something with lots of individual files and/or directories, you probably should use tar to bundle everything up into one big file, then scp that over to the other machine. We covered using tar in a recent TNS story.

I think you’ll find scp a practical addition to your Linux command line toolbox.

Contact Rob “drtorq” Reilly for consultation, speaking engagements and commissioned projects at doc@drtorq.com or 407-718-3274.

TRENDING STORIES
Rob "drtorq" Reilly is an independent consultant, writer, and speaker specializing in Linux/OSS, physical computing, hardware hacking, the tech media, and the DIY/Maker movement. He provides a variety of engineering, business and special project services to individual clients and companies....
Read more from drtorq
SHARE THIS STORY
TRENDING STORIES
TNS owner Insight Partners is an investor in: Simply.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.