4

What I need is to be able to connect reversely to Raspberry Pi that has only GSM connection.

I can send an SMS to trigger some event (for example, to run something), but not sure how it should be done.

What should I run on Raspberry (Debian 7.8, ssh) and on my computer (with Windows with public IP, putty) so it would connect. Is it even possible?

0

3 Answers 3

2

To connect to your Raspberry without public IP, you need reverse port forwarding feature of SSH and also running sshd server on the computer with public ip. Lets pretend that pi is your Raspberry and pc is your computer.

pi $ ssh -NTf -R 22:localhost:2222 pc

then you should be able to connect from your pc to your pi as

pc $ ssh -p 2222 localhost

(or similar with putty) But you might have problems with breaking SSH connections over GSM, because of really large latencies.

2
  • Any info if putty can do that all? Or I need some additional SSH server on Windows? Jan 3, 2016 at 9:53
  • putty is ssh client and not server. Other possibility would be some other server with public IP, you can forward your traffic through.
    – Jakuje
    Jan 3, 2016 at 9:54
2

This answer isn't Pi-specific, but I'd be tempted to try this:

  • Use a dynamic dns service to give your pi a domain name. To do this you sign up for a service (some of them are free, a choice of providers is listed on the Wikipedia page for DDNS) and then you run a small daemon on the pi that connects to the DDNS service and updates it with the new IP address whenever it changes.

  • Then, ssh in the normal way to the domain provided by the DDNS provider. If this is part of an automated process then you'll need to consider the scenario where it fails to connect (e.g. if it fails then try again in 10 minutes)

Hope that's helpful!

6
  • I personally use CloudFlare. Their API is not for the weak, but it gives me almost instant DNS propagation. No stale problems.
    – Aloha
    Jan 3, 2016 at 15:53
  • @PandaLion98, thanks for the constructive edit. Staleness also depends on how frequently the ddns daemon runs on the pi though (not just DNS propagation time). Intervals measured in minutes aren't uncommon as default settings.
    – A E
    Jan 3, 2016 at 15:54
  • Do some additional coding and you'll end up with zero stale time. What I do every 1 minute is check my IP address. If it's the same, carry on. If it's different, change it.
    – Aloha
    Jan 3, 2016 at 15:57
  • 1
    that won't work... told you it's a GSM connection... those are behind NAT that doesn't allow you to listen on any port, so the problem is not with domain, neither IP Jan 3, 2016 at 16:26
  • @FlashThunder, presumably port 80 is allowed? In /etc/ssh/sshd_config set Port to 80 and it'll listen on port 80.
    – A E
    Jan 3, 2016 at 16:34
1

Another option is to install tor and expose SSH via Tor hidden service. On your RPi, you will need to run sshd and configure tor as follows:

    HiddenServiceDir /var/lib/tor/hidden_service/
    HiddenServicePort 22 127.0.0.1:22

Note the hidden service name (which looks like "randomcharacters.onion") which you will connect to.

On your client computer you will need tor running as well. You will also need to make sure SSH will use tor while connecting, e.g.

torify ssh [email protected]

Your Answer

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

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