baconMan
Posts: 3
Joined: Tue Jan 22, 2019 6:00 pm

SSH outside network - port forwarding

Tue Jan 22, 2019 6:07 pm

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!

User avatar
rpdom
Posts: 15567
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: SSH outside network - port forwarding

Tue Jan 22, 2019 6:28 pm

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.

tpyo kingg
Posts: 633
Joined: Mon Apr 09, 2018 5:26 pm
Location: N. Finland

Re: SSH outside network - port forwarding

Tue Jan 22, 2019 8:11 pm

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.

AndersUk
Posts: 9
Joined: Wed Mar 07, 2012 8:41 am
Contact: Website

Re: SSH outside network - port forwarding

Tue Jan 22, 2019 9:33 pm

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.

baconMan
Posts: 3
Joined: Tue Jan 22, 2019 6:00 pm

Re: SSH outside network - port forwarding

Wed Jan 23, 2019 7:00 pm

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?

tpyo kingg
Posts: 633
Joined: Mon Apr 09, 2018 5:26 pm
Location: N. Finland

Re: SSH outside network - port forwarding

Wed Jan 23, 2019 7:13 pm

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.

baconMan
Posts: 3
Joined: Tue Jan 22, 2019 6:00 pm

Re: SSH outside network - port forwarding

Wed Jan 23, 2019 11:30 pm

I get:

ping6: nodename nor servname provided, or not known

Thanks so much for your help, by the way.

tpyo kingg
Posts: 633
Joined: Mon Apr 09, 2018 5:26 pm
Location: N. Finland

Re: SSH outside network - port forwarding

Thu Jan 24, 2019 6:07 am

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.

Return to “Troubleshooting”