-1

I cannot find how to ssh into raspberry pi from the outside network. I have set up port forwarding, on port 80 for my raspberry pi. I have used https://httpbin.org/ip to obtain the ip address of my computer. I have used DHCP to bind the MAC of my raspberrypi to a particular IP on my localhost, suppose it is: 192.168.0.111.

When I access it locally, it is simply like: ssh [email protected] and that is it. But how would I do it from outside network? How would I remotely ssh into it now? The following does not work:

ssh pi@<myip> -p 80

so if the ip from httpbin.org is 10.20.30.222, then I would do:

ssh [email protected] -p 80

It feels as if I'm not using the piece of information that is the highlighted part here: 192.168.0.111. Can someone please help me with the right syntax?

Thanks

5
  • Just substitute the external IP you got from httpbin.org and the forwarded port. Obviously, the external IP can't be 192.168.xxx.xxx. Sep 12, 2018 at 23:10
  • Sorry I don't follow.
    – Naz
    Sep 12, 2018 at 23:14
  • Suppose my external ip from httpbin.org is 10.20.30.222
    – Naz
    Sep 12, 2018 at 23:15
  • 1
    ...then you'd do ssh [email protected] -p 80. If it doesn't works, something is wrong with port forwarding. Sep 12, 2018 at 23:18
  • let me try this again tomorrow. That is what I did initially. Thanks
    – Naz
    Sep 12, 2018 at 23:27

2 Answers 2

0

The external port in this case should be port 80 and it should be forwarding to port 22 ip 192.168.0.111 (your Rpi IP address and default ssh port). You should configure all this on your home router.

Then you should be able to connect to your pi by doing:

ssh [email protected] -p 80

If you want to use port 80 in your raspberry then you can change the default ssh port on your RPi in /etc/ssh/sshd_config to port 80.

2
  • Hi Tomas, thanks. I do not follow the part where you say that the external port should forwarding to port 22 ip 192.168.0.111
    – Naz
    Sep 13, 2018 at 0:09
  • On your router look for port forwarding and set: External port 80 maps to port 22 IP 192.168.0.111. Then you should be able to do: ssh [email protected] -p 80. You router will forward incoming connections (to port 80 of your router) to port 22 of your RPi Dec 5, 2018 at 4:08
0

This has already been answered here. I will shortly rephrase a very convenient solution using SSHHub (disclamer, I am the author). It uses ssh's own forwarding to access your Rasperry PI from anywhere. Its reliable, free and pretty simple to setup. Register once:

ssh [email protected] register

run on your Raspberry PI:

while true; do ssh [username]@sshhub.de -R 22:localhost:22 -N -o ServerAliveInterval=10; sleep 10; done

...and thats it! You can connect your Raspberry Pi from anywhere:

ssh -J [username]@sshhub.de localhost

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .