I have a Raspberry which is connected to a local network with Wifi. The local network can be any open Wifi-Network. I don't have any access to the Router of that network, so I can't use port forwarding or something like that.

The solution should support connect, disconnect and send commands from outside to the Raspberry. I only want to connect to the device if it is necessary and than quit, I don't want to hold the connection forever.

My target is to send a Videostream to an iPhone. I would like to controle the Raspberry from the iPhone.

Three solutions I found are not matching to my problem:

  • Reverse SSH (Connection would be permanent open or rather I don't know how to connect from outside to the Raspberry if it is possible at all.)
  • The Weaved Kit (I prefer to use own code)
  • Use a second Raspberry as VPN (I'm not sure how and I don't know the possibilities and restriction of this solution if it is possible at all)

(A second Raspberry as Server/ Access Point or something occured to me, but I still don't figuered out how to connect the devices)

  • I've closed this as off-topic since I believe your first task should be to investigate whether it is possible to do this, with no persistent connection, using any kind of computer what-so-ever. Clue: It isn't without involving a third party; once you've decided what that might be you may have a pi-specific question. – goldilocks Oct 12 '15 at 22:01

I use Reverse SSH for SSH across a network when I cannot forward the ports on the server.

Just have your Pi run bash -i >& /dev/tcp/xx.xx.xx.xx/1337 0>&1 every minute or so using crontab (or by some other way) and on your computer/client run the command nc -l -k 1337 and just keep that running. You will have to forward port 1337 on the network that your client is on.

Step by step

[First forward port 1337 on the network you are on, not the Pi's network.]

On the client: nc -l -k 1337

Then on the Pi: bash -i >& /dev/tcp/xx.xx.xx.xx/1337 0>&1 where xx.xx.xx.xx is your clients public IP.

Make sure you set a static IP on the client and and forward the port to that IP.

| improve this answer | |
  • Why on Earth do you use netcat instead of SSH? This is very insecure. The whole purpose of SSH is to encrypt your session's data, which netcat won't do for you. – Dmitry Grigoryev Sep 23 '19 at 7:00
  • To answer your question: I used netcat only in this one specific scenario; where SSH is not an option because forwarding ports on the network is not possible. SSH is always preferred, for exactly the reason you mention. This answer is nearly four years old, if you have a better solution, you are welcome to post it. – Patrick Cook Sep 23 '19 at 21:07

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