If you are a Raspberry Pi 3 or 4 user, the on-board Wi-Fi radio is probably more than just a convenience, but also a great productivity tool. This guide will show you how to transfer files between a Raspberry Pi and a Windows 10 machine over a Wi-Fi network using the Windows command prompt.
Notice of Non-Affiliation and Disclaimer: As of the publication date, we are not affiliated with, associated with, authorized with, endorsed by, compensated by, or in any way officially connected with the Raspberry Pi Foundation, SSH.com, or Microsoft, or their owners, subsidiaries or affiliates.
External Links: Links to external web pages have been provided as a convenience and for informational purposes only. Unboxing Tomorrow and Voxidyne Media bear no responsibility for the accuracy, legality or content of the external site or for that of subsequent links. Contact the external site for answers to questions regarding its content.
Material Resources
To get started, you should already have a working copy of the Raspberry Operating system (formerly called Raspbian OS). And your Raspberry Pi should already be able to connect to your network. If you are starting fresh, then I recommended reading the Raspberry Pi 4 Setup for Windows Users guide first. In total, you need:
- Raspberry Pi
- Raspberry Pi Operating System
- Admin Rights on your router
- User password for the Raspberry Pi
- (Recommended) Admin Rights on your Windows computer
- (Recommended) Anti-Malware Software
Enable SSH on the Raspberry Pi
Configure your Raspberry Pi to allow Secure Shell (SSH) services first. Open a terminal and enter:
sudo raspi-config
Navigate the menu to enable SSH.
Download PuTTY for Windows
Next, get a copy of the PuTTY application from the https://www.putty.org website. If you are confident you already have PuTTY installed, skip ahead to the “Example ” section below.
PuTTY is an SSH client developed for Windows platforms. It includes an additional resource called PuTTY Secure Copy (PSCP). PSCP is the tool for transferring files securely over an SSH connection.
Scan for Malware
As with everything you download from the internet, scan it with your favorite anti-malware tool and then run the application. As of this writing, the application installer is putty-64bit-0.74-installer.msi.
Install PuTTY with the PATH Option Enabled
Run the installer, and make certain you enable “Put install directory on the PATH for command prompts.”
Follow the additional instructions until the application is installed.
Windows: Open the Command Prompt
Open the Windows command prompt by searching for “cmd” in the Windows Search bar. Because of how sluggish Windows Search is, you can alternatively press WIN+R, and then enter “cmd.”
Test PSCP
Test the application by simply entering “pscp.exe.” If your installation was a success, then you should see a manual for the application appear.
Raspberry Pi: Find the Username and IP Address
Now you need to figure out your Raspberry Pi username and local internet protocol (IP) address.
By default, your username will be “pi.” But the terminal will verify your username if you type…
whoami
IP Address Method 1
With the Raspberry Pi’s terminal still open, the easiest way to get your local IP address is to ifconfig. Search the result for the inet value.
IP Address Method 2
Alternatively, log into your wireless router or hotspot, and then search for a host named “raspberrypi” or similar. Because every router is different, you must refer to the manufacturer’s instructions on exactly how to do this.
Windows: Open the Command Prompt
Once you know the IP address of the router, return to the Windows command prompt.
Example 1: Pi to Windows Transfer
I will demonstrate by first transferring a file named “example.txt” from the home directory of the pi to a Window directory at C:\test. Note the Linux path uses a forward slash (/), while the Windows machine has a backslash (\).
pscp.exe -P 22 pi@10.0.0.119:/home/pi/example.txt C:\test
If your Windows path contains spaces, then you will need to enclose it in double-quotes. For example:
pscp.exe -P 22 pi@10.0.0.119:/home/pi/example.txt “c:\test with space”
This string is formatted according to Figure 6 below. If its accepted, then you will be prompted for your Raspberry Pi user password before the transfer will take place.
Example 2: Windows to Pi Transfer
To reverse the direction of transfer, just rearrange as follows…
pscp.exe -P 22 C:\test\example2.txt pi@10.0.0.119:/home/pi/
Dealing with “ssh_init: Network error: Cannot assign”
If port 22 is not yet set up as the default port on your PuTTY/PSCP installation, you will need to specify it every time by adding the “-P 22” argument. Otherwise, you will get an error.
To avoid needing to type “-P 22” every time, run the PuTTY application in Windows. Then set the following parameters…
- Select Port 22
- Saved Sessions = Default Settings
- Click the “Save” Button
Closing Remarks
In my case, typing out “pscp” instead of “pscp.exe” was acceptable, which might save you a little time.
The ease of transferring files this way is one of the many reasons why you should change your Raspberry Pi’s password from the default value of “raspberry.” Otherwise, we can easily imagine how a bad actor on our own local network might tamper with your file system.
For good measure, it is best to check back for updates and security improvements to the PuTTY client. The change notes are also a nice way to learn about how the PuTTY project is progressing.
References
[1] | B. Mayes, “Raspberry Pi 4 (8GB) Setup for Windows Users,” Voxidyne Media, 9 June 2020. [Online]. Available: https://unboxing-tomorrow.com/raspberry-pi-4-8gb-setup-for-windows-users/. [Accessed 22 Oct. 2020]. |
[2] | “Download PuTTY – a free SSH and telnet client for Windows,” Putty.org, [Online]. Available: https://www.putty.org. [Accessed 18 Oct. 2020]. |
[3] | “Download PuTTY: latest release (0.74),” PuTTY.org, [Online]. Available: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html. [Accessed 18 Oct. 2020]. |
[4] | SSH Communications Security, Inc., “CHAPTER 5: USING PSCP TO TRANSFER FILES SECURELY,” SSH Communications Security, Inc., [Online]. Available: https://www.ssh.com/ssh/putty/putty-manuals/0.68/Chapter5.html. [Accessed 19 Oct. 2020]. |
Important Notice: This article and its contents (the “Information”) belong to Unboxing-tomorrow.com and Voxidyne Media LLC. No license is granted for the use of it other than for information purposes. No license of any intellectual property rights is granted. The Information is subject to change without notice. The Information supplied is believed to be accurate, but Voxidyne Media LLC assumes no responsibility for its accuracy or completeness, any error in or omission from it or for any use made of it. Liability for loss or damage resulting from any reliance on the Information or use of it (including liability resulting from negligence or where Voxidyne Media LLC was aware of the possibility of such loss or damage arising) is excluded.