简体   繁体   English

Raspberry Pi SSH反向隧道,它如何工作? 帮助设置

[英]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... 我一直在尝试使用树莓派,并且我想在树莓派上使用gpio进行一些家庭自动化实验,但是我希望将其连接到互联网,以便可以从任何地方读取状态并进行更改。 ..

I have been reading that a reverse ssh connection is the best way to achieve this since it is safe. 我一直在读,反向ssh连接是实现此目的的最佳方法,因为它是安全的。

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. 我阅读的内容背后的想法是,如果我有一个可供使用的Web服务器(我将使用我公司的服务器进行测试,他们不会介意),则可以从pi SSH到它,然后从我的计算机SSH到它,并连接到服务器后,我可以通过安全外壳控制pi。

my question is, since the pi is making the connection to the server, will this cause any firewall problems? 我的问题是,由于pi正在建立与服务器的连接,这会引起任何防火墙问题吗? 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? 我想这样做,以便只要我们都连接到互联网,就可以在任何地方使用pi并从任何地方访问它,如果不是因为这个原因,我会创建一个vpn,但是,如果我更改了例如,对于我公司的pi,我将无法在家中对其进行控制...了解我的意思以及为什么要研究此反向隧道选项?

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? 另外,在未来的道路上,我的计划是创建一个Web界面来控制pi,我能否拥有一个JavaScript界面​​并通过apache将ssh命令发送到pi?

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? 您当然可以只在Pi上安装apache并创建API或排序?

For the SSH part though, see this quick read: http://www.vdomck.org/2005/11/reversing-ssh-connection.html 不过,对于SSH部分,请参阅以下快速阅读: 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. 在您的情况下,我假设Pi将是“防火墙”设备,公司Web服务器将是某种“网关”。 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: 现在,Web服务器正在侦听端口10000,并转发到端口22的pi。在笔记本电脑上:

ssh username@localhost -p 10000

(username is the Pi username) This will connect to the Pi via the webserver. (用户名是Pi的用户名)这将通过Web服务器连接到Pi。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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