How to Transfer Files to the Raspberry Pi using SFTP


WinSCP Screenshot

After setting up the Raspberry Pi, you’ll likely need to transfer some files to it.  Since the Pi already has an SSH server, you can use SFTP to transfer files to your user’s home directory.  Read past the break to have a look at using WinSCP to transfer files.

Download and install an SFTP client for Windows.  I use WinSCP which can be found here.

  • After installing WinSCP, launch it from the start menu.
  • Provide the Pi’s IP address in “Host name:” text box
  • Enter your username in “User name:” and your password in “Password

WinSCP Login

  • Similar to setting up PuTTY you will be prompted to accept a security key. Click “Yes” to accept.

Accept Unknown Key

  • You can now drag and drop files from the left pane to the right pane

File Upload Pane

  • Upon dragging a file over to the right pane you will see this box asking where to put the file.  You should be able to upload to your home directory and nowhere else.  You can copy to your home directory and then move the file wherever you want with an SSH shell.

Copy Files

  • Click “Copy” to complete the transfer.  You can then move the file wherever you want with the cp command in the SSH shell.

If you’ve got a LAMP server set up, you could move files into /var/www to have Apache serve the files up.  You could use this to upload PHP and HTML files to write a website served by the Pi.  Anyway, you’ve now got read and write access to your Pi’s file system.


Advertisement

5 Comments

Name
A name is required.
Email
An email is required.
Site
Invalid URL

  1. Hi Chris,

    I got a question here. I want to update files in the /var/www/ directory of the pi but it seems like I dont have the permissions. Are there any commands that would fix this?
    Cheers Richard


    • Owen Page February 13, 2017

      Login to your pi and type the following command:
      sudo nano /etc/ssh/sshd_config

      Once in the nano text editor use the arrow keys to navigate down to where it says PermitRootLogin and make sure it is followed by yes and not anything else.

      Then hit Ctrl+X followed by Y and enter to save and exit nano.
      Next you’ll need to change your root password. Do this using:
      sudo passwd root

      PASSWD IS NOT A TYPO
      Once you have changed the password, go back to WinSCP and now login using root and your newly created password instead of pi and raspberry.


  2. Anonymous August 4, 2013

    I thought that was a joke lol


  3. Anonymous May 30, 2013

    very good question 😛


  4. Anonymous May 19, 2013

    What’s the point of blacking out your internal IP address…