简体   繁体   中英

Raspberry pi SSH reverse tunnel, how does it work? Help setting it up

I've been experimenting with a raspberry pi, and I would like to do some home automation experiments with the gpio on the raspberry, but I would like it to be connected to the internet so I could read the state and make changes from anywhere...

I have been reading that a reverse ssh connection is the best way to achieve this since it is safe.

The ideia behind what I read is that if I have a web server available for use (i will be using my company's for testing, they won't mind) I can ssh to it from the pi and then ssh to it from my computer, and after ssh'ing to the server, I can control the pi via a secure shell.

my question is, since the pi is making the connection to the server, will this cause any firewall problems? It shouldn't since it's an outbound connection, and that is the actual advantage of doing this from what i understand...

I want to make it so that I can have the pi anywhere and access it from anywhere as long as we are both connected to the internet, if it wasn't for this i would just create a vpn, but then, if I changed the pi to my company for example, i wouldn't be able to control it from home... Understand what I mean and why I am looking into this reverse tunnel option?

Also, a bit further down the road, my plan is to create a web interface to control the pi, will i be able to have a javascript interface and send ssh commands to the pi via apache?

Thank you for your time, if any further info is needed, just ask :)

You could of course just install apache on the Pi and create an API or sorts?

For the SSH part though, see this quick read: http://www.vdomck.org/2005/11/reversing-ssh-connection.html

I am assuming in your case the Pi would be the 'firewalled' device and the company webserver the 'gateway' of sorts. If this assumption is correct:

ssh -f -N -R 10000:localhost:22 username@ip_address_of_webserver

Now the webserver is listening on port 10000 and forwarding to the pi on port 22. On your laptop:

ssh username@localhost -p 10000

(username is the Pi username) This will connect to the Pi via the webserver.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM