Page 1 of 1

SSH outside network - port forwarding

Posted: Tue Jan 22, 2019 6:07 pm
by baconMan
Hi!

I am trying at ssh into my raspberry pi from outside my network. I am forwarding to port 22 which is connected to my pi's IP address.

When I try to ssh into the pi I get the following:

Code: Select all

ssh pi@192.168.xxx.xxx

Code: Select all

ssh: connect to host 192.168.xxx.xxx port 22: Connection refused
Thanks for your help!

Re: SSH outside network - port forwarding

Posted: Tue Jan 22, 2019 6:28 pm
by rpdom
baconMan wrote:
Tue Jan 22, 2019 6:07 pm
I am trying at ssh into my raspberry pi from outside my network.
192.168.x.x is a private network address which cannot be accessed externally. You need to use your publicly accessible IP address which will then be routed to your Pi by the port forwarding you have set up on your router.

Re: SSH outside network - port forwarding

Posted: Tue Jan 22, 2019 8:11 pm
by tpyo kingg
You can find your external IP address using a service like CanYouSeeMe http://canyouseeme.org/

However, that number will probably change often so you'll do better to sign up for a Dynamic Domain Name Service.

Of course all that is predicated on your router having an external address and not behind layers of NAT.

Re: SSH outside network - port forwarding

Posted: Tue Jan 22, 2019 9:33 pm
by AndersUk
If you've got access to another server you can use a Reverse SSH Tunnel https://bends.se/?page=anteckningar/nat ... reversessh which allows you get out from behind a firewall safely.

AutoSSH https://www.everythingcli.org/ssh-tunne ... t-autossh/ can help automate and keep connections up and running.

Re: SSH outside network - port forwarding

Posted: Wed Jan 23, 2019 7:00 pm
by baconMan
I think that my external address is an IPv6 address. It contains letters and numbers in the second half. It does not begin with

Code: Select all

fe80::
.
(I followed these instructions: https://techoverflow.net/2018/06/09/ho ... 6-address/)

When I try to ssh into the Pi I get the following:

Code: Select all

port 22: No route to host
Any ideas?

Re: SSH outside network - port forwarding

Posted: Wed Jan 23, 2019 7:13 pm
by tpyo kingg
Can you ping the router from the outside using ping6?

e.g.

Code: Select all

ping6 -c 2 -w 1 2a00:1450:400f:80b::2004
Substitute your IPv6 address there instead.

Re: SSH outside network - port forwarding

Posted: Wed Jan 23, 2019 11:30 pm
by baconMan
I get:

ping6: nodename nor servname provided, or not known

Thanks so much for your help, by the way.

Re: SSH outside network - port forwarding

Posted: Thu Jan 24, 2019 6:07 am
by tpyo kingg
What happens when you try either ping or ping6 with the IP address shown when you try http://canyouseeme.org/ from home?

Edit: An alternative would be to use your router's admin interface to look up its external IP number.