![]() In order to access Raspberry from another machine, we have to first ssh to the VPS # ssh then logging in Raspberry from the VPS: # ssh localhost -p 3333 Step four – Connecting to the SSH tunnel from another machine Step three – Connecting to the SSH tunnel from VPSĪfter we’ve created the tunnel with the command at step 1, Raspberry can be accessed by executing the following command on the VPS: # ssh localhost -p 3333 Pkts bytes target prot opt in out source destinationĬhain FORWARD (policy ACCEPT 0 packets, 0 bytes)Ĭhain OUTPUT (policy ACCEPT 33 packets, 5915 bytes) # iptables -L -vnĬhain INPUT (policy ACCEPT 39 packets, 4642 bytes) In this case we don’t have to do any settings in iptables. My iptables on VPS has the default configuration, so is not dropping any packets. I’ve opened port 3333 in the Firewall on the management web-interface of the VPS. – user and IP address of the VPS, replace with your actual user and IP.We’ll start by setting up the reverse SSH tunnel on the Raspberry Pi by typing in the following command: # ssh -R 3333:localhost:22 3333 – the port used for the reverse SSH tunnel (port should be opened on VPS). Note: We are working with root user, if you are not logged in as root, add sudo in the front of the commands. Step two – Setting up a reverse SSH tunnel It is also very easy to set up and it has a very nice and intuitive interface. I am living in Germany and I chose a VPS solution from At the time I’m writing this article, the solution is very affordable, only 1Euro/month and you get 1Core CPU, 0,5GB and 20GB SSD. Or even better, we can choose a VPS (virtual private server) solution from one of the many providers. For this solution we’d need a Linux computer that will be anytime available and directly accessible from Internet. I would like to be able to access the Raspberry Pi from anywhere, not only from my local computer. I’ll write more about this project in a different post, for now let’s focus on ssh tunnel subject, which is quite a challenging part. The Raspberry Pi is used in a remote house to convert a classic alarm system to a smart alarm (with Internet and SMS functionality). My concrete case where I need this kind of implementation is a Raspberry Pi connected to Internet using a 3G USB dongle. How can you achieve this, I’ll explain you in the following lines. Reverse SSH tunneling allows you to create a connection from the remote computer to a local computer and using this established connection to set up a new connection from your computer back to the remote computer. This computer could be placed behind a firewall or a router (NAT) whose rules or settings cannot be changed.Īn easy and practical solution that could help us in this case is to set up a reverse SSH tunnel on Linux. There are cases when a remote computer could be hard to reach.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |