I was nearing the end of a Raspberry Pi instructable and decided I should include a file to help the reader avoid typing errors in a long RasPi script. If the reader is viewing the instructable on his/her RasPi, downloading can be slow but straight forward. From there there code could simply by run. However, what if the reader is viewing the instructable on his/her PC (which is what I would do)? The downloaded file to the PC must then be transferred to the RasPi. How best can this be accomplished?
This short instructable shares the easiest method I have found to transfer files between the RasPi and a PC - in either direction.
What We'll Need
RasPi as set up with SSH (see Raspberry Pi Made Easy - Part 2 (running headless and loving it)
A PC (again I'm using a Windows 10 PC)
Both require Internet connections.
Step 1: Setting Up Secure Copy
While transferring files through cloud repositories (Dropbox, Google Drive, to name but two of many) is an easy option, I think using SSH (Secure Shell) and SCP (Secure Copy Protocol) is an even easier option since we have already established SSH on our RasPi (see Raspberry Pi Made Easy - Part 2 (running headless and loving it). More can be read bout SCP here.
We don't have to do anything to our RasPi other than know its IP address (again, see the above mentioned instructable if you need to know how to find it.) All we need to do is set up SCP on our PC.
Double click the downloaded WinSCP-5.9.1-Setup.exe to install it. Note that your download could have a different name if the program has been updated since this writing. Complete the default full install/upgrade. (Figure 1.)
Once installed, the Login dialog will open (Figure 2.) The left panel will display available sites once they are setup. Ensure the File protocol selected is SFTP. Enter the IP address of your RasPi (or other destination Internet connected computer) into the Host name field. Ensure the Port number is 22. Enter your user name and password in the appropriate fields. The default user name is pi; the default password in raspberry. If you have changed them on the RasPi, use the current ones.
Clicking the Save button will add your current site to the left panel so you can simply select it and all fields in the right panel will be automatically filled.
WinSCP will attempt to connect to the remote computer (your RasPi) (Figure 3.) It may pause asking for your password again. If so, simply re-enter your password and click the OK button.
WinSCP's Desktop finally opens (Figure 4.) The main portion of the windows is divided into two panels. Files listed in the left panel reside on the host computer (your PC); files listed in the right panel reside on the remote computer (your RasPi.)
You can copy files in either direction - from the RasPi to the PC, or, from the PC to the RasPi.
Navigate each panel to the appropriate source and destination folders/directories. Then simply drag the files of interest from the source panel to the destination panel.
You'll notice the top menu has a lot of buttons and menu items. These are an indication that we are using a small part of WinSCP's potential; however, if you never learn more about it than you now know, you are well equipped for our current needs.
Step 2: All Done
This short instructable can save you many hours of frustrating reproduction of files between computers. I hope you find the solution presented simple and effective; I know I have.
Please point out any errors or omissions. Thank you for reading.