Hi I have followed this guide https://pimylifeup.com/raspberry-pi-security-camera/ and setup a multi camera surveillance system using my pi a few usb cameras and 3 ip cameras.

I would like to access my pis webpage from my iphone over the internet when I am far from home. I would like my connection to be encrypted and safe from eavesdropping.

After some research I found that using a ssh tunnel would be the best way, I have found this guide https://charlesreid1.com/wiki/RaspberryPi/SSH_Stunnel but am confused to how the whole tunnel works?

Do I install stunnel on the motionpi? So its the "command and control server" the guide talks about or do i setup this command and control server on another system?

Any help with explanation of how ssh tunnels work and how to get the desired setup running is greatly appreciated.

2 Answers 2


If you are using Stunnel, you probably don't need an SSH tunnel unless you have a specific reason. Stunnel is designed to work as a TLS encryption wrapper between client and server so that whatever communication can be run over the TLS connection. If your purpose is solely to view your webcam via a secure channel, you can simply use ssh to create a tunnel like this:

ssh -f user@remoteServerIP -L 8080:webCamIP:8080 -N
  • -f tells ssh to run in the background just before command execution.
  • -L specifies that connections to the given TCP port on the client are to be forwarded to your internalCam IP address and port.
  • -N tells the remote system to not execute a remote command.

Once the ssh tunnel is established, you can point your browser to your webcam just like you are at home.


Stunnel is a simple way to provide remote access to a particular service on your raspberry pi - provided that you can open ports on your firewall/router AND have either a static IP address or Dynamic DNS services. If you're not very savvy on networking and the term "NAT" doesn't mean anything to you, this is probably more complicated than you want to attempt.

There are a number of other ways to remotely access your raspberry pi at varying costs:

Lastly. If port forwarding isn't that scary to you, you could setup your webpage with SSL internally - then forward that to the outside world. There are a number of tutorials on how to password protect Apache/Nginx.

  • I am ok with networking, I have a sftp server with keys setup. I am not sure why you are recommending paid/third party options? I can access my pi over the internet through SSH for free, I have dyndns setup. What I want to accomplish is to view the motion pi webpage through a secure ssh tunnel.
    – Hani Umer
    Nov 3, 2016 at 6:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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