简体   繁体   English

使用 Raspberry pi 进行海外 SSH

[英]SSH overseas with Raspberry pi

I currently have my Raspberry pi setup with network connectivity and i can connect to it via local ip addres like this: 192.168.0.x我目前的 Raspberry pi 设置具有网络连接性,我可以通过这样的本地 ip 地址连接到它:192.168.0.x

Is there anyway i use my puplic ip to ssh into my raspberry pi ?无论如何,我是否使用我的公共 ip ssh 进入我的树莓派?

There are two possible solutions to this problem.这个问题有两种可能的解决方案。

  1. If your ISP provides public ip, you can use dynamic DNS services from no-ip or dyndns or any other equivalent service providers and you can forward port #22 to rpi ip using your router menu.如果您的 ISP 提供公共 ip,您可以使用来自 no-ip 或 dyndns 或任何其他等效服务提供商的动态 DNS 服务,并且您可以使用路由器菜单将端口 #22 转发到 rpi ip。

  2. If your ISP doesn't provide public ip and you are behind NAT.如果您的 ISP 不提供公共 ip 并且您在 NAT 后面。 You can make use of reverse remote ssh method mentioned in this link.您可以使用此链接中提到的反向远程 ssh 方法。 But to access via this method, you need a server in between that's having a public ip.但是要通过这种方法访问,您需要一个具有公共 ip 的服务器。 http://www.tunnelsup.com/raspberry-pi-phoning-home-using-a-reverse-remote-ssh-tunnel http://www.tunnelsup.com/raspberry-pi-phoning-home-using-a-reverse-remote-ssh-tunnel

Hope it helps.希望能帮助到你。

I think a Dynamic DNS is usualy the way to go.我认为动态 DNS 通常是要走的路。 I use FreeDNS and I think it's pretty good.我使用 FreeDNS,我认为它非常好。 Instructions for setup by dentaku65: dentaku65 的设置说明

First of all register your account on Freedns .首先在Freedns上注册您的帐户。 Freedns offers a bunch of domain names, from my taste the best ones (or the ones easy to remember) are: Freedns 提供了一堆域名,根据我的口味,最好的(或容易记住的)是:

  • mooo.com mooo.com
  • ignorelist.com忽略列表.com

Assume that you register: your_host>.ignorelist.com假设你注册了: your_host>.ignorelist.com
Install inadyn:安装 inadyn:

 sudo apt-get install inadyn curl

Open the url: http://freedns.afraid.org/dynamic/打开网址: http://freedns.afraid.org/dynamic/ : http://freedns.afraid.org/dynamic/
Login with your account使用您的帐户登录
Select the link Direct URL beside .ignorelist.com选择 .ignorelist.com 旁边的链接 Direct URL
Copy everything from the right of the ?从 ? 的右侧复制所有内容。 in the address bar (alphanumeric string)在地址栏中(字母数字字符串)

Create configuration file of inadyn:创建 inadyn 的配置文件:

 sudo gedit /etc/inadyn.conf

And save this content:并保存此内容:

 --username <your_username> --password <your_password> --update_period 60000 --forced_update_period 320000 --alias <your_host>.ignorelist.com,alphanumeric string --background --dyndns_system default@freedns.afraid.org --syslog

Add inadyn to crontab:将 inadyn 添加到 crontab:

 export EDITOR=gedit && sudo crontab -e

Edit the file to add the following line:编辑文件以添加以下行:

 @reboot /usr/sbin/inadyn

Reboot your PC重启你的电脑
Wait 3 minutes等待 3 分钟
Check if inadyn is running:检查 inadyn 是否正在运行:

 ps -A | grep inadyn

Check inadyn behaviour:检查 inadyn 行为:

 more /var/log/messages |grep INADYN

Check if your host is up:检查您的主机是否已启动:

 ping <your_host>.ignorelist.com

您可能需要在路由器上启用端口转发

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

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