3

I am looking for a way to send files from a computer to a rpi without the rpi being able to send anything to the pc and therefore possibly get access the computer's network. The rpi will be used as a router/server that devices from the outside can connect to and access certain data. Consequently, the one-way-connection is somewhat crucial.

I have already read that a connection via USB cable with the rpi as client is extremely difficult, if not impossible. Another idea would be to connect via bluetooth, but I actually do not know how/if that can be done. Any experience on that idea?

Besides that, I am pretty much out of ideas. Do you have any thoughts on how to solve the problem?

  • 1
    File Transfer Protocol? With some user management. Please do not thank in the question. Press upvote and accept answers. Also read the FAQ- Thanks - PS How are you using it as a router. Running pfsense on it or what? – Piotr Kula Jul 16 '13 at 16:09
  • Is the RPi a router or a server or both? I'm not sure how it will route if you don't want it accessing the computer's network. By definition a router must be able to access the network. – Craig Jul 16 '13 at 19:01
  • To clarify the issue: The rpi is getting some files from network A via PC A and it creates network B, in which it acts as router and also as an apache-server. The devices connect to network B and can read the files. The rpi should have as limited access to network A as possible (security policy), that is why I came up with the idea of a USB-stick in the first place. I'm running hostapd on the pi to create my own network. – hmkt Jul 17 '13 at 6:52
  • What I am looking for now is the best way to get the files from PC A to the rpi (while ideally not having the rpi connected to network a via wlan) – hmkt Jul 17 '13 at 7:02
3

I'm going to take this apart a little bit:

I am looking for a way to send files from a computer to a rpi without the rpi being able to send anything to the pc and therefore possibly get access the computer's network.

I hate to be a stickler, lol, but you need to clarify some things, because on a literal level this is not possible. ALL network communication requires a two way relationship. If you initiate a connection with another computer, the ONLY way for that connection to be established is for that computer to send back a response.

The rpi will be used as a router/server that devices from the outside can connect to and access certain data.

If the other computers are supposed to access "certain data", how are they supposed to receive it if this is a "one-way" connection? Accessing data means sending a request, and then receiving a response. That's two-way communication.

That said, it is possible to use a firewall to allow a connection to be initiated from the outside (resulting in two way communication) but not from inside (meaning, the pi can't establish a connection, only reply to one). I presume that's what you are after.

If you are using some form of linux (eg. raspbian), the way to do that is via iptables. Here's a couple of tutorial links:

http://www.thegeekstuff.com/2011/01/iptables-fundamentals/

http://www.thegeekstuff.com/2011/06/iptables-rules-examples/

Basically, you want a set-up that rejects everything in the OUTPUT chain except for things that have state RELATED,ESTABLISHED.

2

SFTP (ssh) would definitely be your best bet. By setting it up with the proper key configuration you wouldn't even need to login, just shove the file.

EDIT: I see in one of your comments to your question that you've asked not to use a wlan connection. If you want to do that over the network your only option would be a usb-wifi dongle. Other than that there isn't a way to send/receive files through a network. You'd have to use USB.

2

Here is my understanding of the problem. For various reasons you need to get files from a PC to the Raspberry pi without a network connection.

Given that constraint you could connect the PC to the Raspberry Pi using a USB->serial cable.

You will need to disable the serial console and serial login on the Raspberry Pi. Follow these instructions.

As an alternative to using the serial port on the GPIO header you could just get 2 USB->serial cables with standard DB9 connectors like this and a standard DB9-DB9 null modem and use these to connect the computer to the RPi using the USB ports.

Once you have them connected via the serial cable you need a way to use it to transfer files. I haven't done this in quite a long time but my starting point would be Kermit which can run in server mode on the Raspberry Pi and have a scripted client on the PC. Kermit is designed for sending files without errors over unreliable connections. Since the PC will initiate the communication this connection will be difficult to exploit.

  • In principle, if you are really paranoid, you can wire the serial cable only in one direction. TX on the PC to RX on the Pi, but not the other way around. Of course the PC will not be able to determine if the data was sent correctly. – Frepa Jul 18 '13 at 22:17
1

I agree with @ ppumkin's comment. FTP or TFTP should fit the bill. Setup the server on the Pi, restrict R/RW access to a single folder, and depending on your application, setup a listener script on the RPi to move the file out of that folder once the transfer has been finished.

Another option would be to setup a webserver with an upload page. Browse to the file on your computer and click the upload button. Check W3Schools for an example

1

if you do not allow any network connection between you Pi and PC, the only viable transfer method would be an USB stick or any kind of flash memory you copy files from your PC to and subsequently copy from on your Raspberry Pi.

0

The protocol you want is SCP over SSH (which means that SSH must be enabled). Transferring files using SCP via the command line is a pain but you can install programs like FileZilla that make this really easy.

See How to Configure Your Raspberry Pi for Remote Shell, Desktop, and File Transfer

  • how'd you propose to use scp without access to the network? please, read the question more carefully. – lenik Jul 30 '13 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.