You are not logged in.

#1 2014-08-16 20:29:42

xworld
Member
Registered: 2012-05-27
Posts: 153

Remote SSH and Port Forwarding

I have an Arch server running SSH on port 12444 which I am trying to be able to access from outside my network. I've already viewed this thread: https://bbs.archlinux.org/viewtopic.php?id=179561, but his solution does not work for me. I already confirmed that SSH is indeed working and listening on the specified port. I have an Actiontec C1000A and am using a PPPoE connection like the user in the thread above. I configured it to forward the same port the the LAN address of the SSH server. Once I leave my network and log in somewhere else, I find that the connection eventually times out on the port specified. If I run a scan it shows that the port is completely filtered. This is rather weird considering that I also disabled all firewalls including the one on the router. I restarted the router just to be sure, but to no avail. I still can't connect remotely to the router.

I also tried to enable Remote GUI and Remote Console. Both the GUI port and Telnet where filtered, and I could not connect to either of them. So essentially the router is simply doing the opposite of what I tell it to. I have dynamic DNS enabled so I'm positive that I'm using the correct WAN IP address when I try to log in. Just to be sure, this is how I log in:

ssh -i /priv/key -p 12444 sshserveruser@wan.ip.addr.xx

I also try without specifying a user. No dice. Nothing works. No ports that I open, or forward, seem to work. At all.

Offline

#2 2014-08-16 20:33:09

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Remote SSH and Port Forwarding

What is the `.xx` supposed to represent?

Run ssh with verbose flags to generate some more meaningful error messages....


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2014-08-16 20:45:34

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,354

Re: Remote SSH and Port Forwarding

jasonwryan wrote:

What is the `.xx` supposed to represent?

Run ssh with verbose flags to generate some more meaningful error messages....

I think he is saying the address is the four bytes expressed as decimal separated by dots -- IPv4 style   (like 116.117.118.4)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#4 2014-08-16 21:05:10

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,354

Re: Remote SSH and Port Forwarding

I think, but I am not certain, that you have an incorrect concept as to how this works.  If I may...

When you forward a port on ssh, you usually still connect to ssh on port 22.  I think you are trying to forward port 12444, which presumably has some custom server sitting on it on your host (A game, something you wrote, etc...).   If you can hit that port from your host at localhost:12444, or from your lan at your.private.ip.address:12444, then this is the case.

What I think you want to do is connect to  sshd on port 22 using the ssh  -L option to forward port 12444.   What happens is that sshd on the host then opens a connection to its own localhost:12444 and sends that information through the ssh connection on port 22.  At the client end, the ssh client opens a listener at its localhost:12444 and uses that as the endpoint for the data coming through the ssh pipe.  If your server on the host on port 12444 happened to serve up http stuff, one could run a browser on the client machine and surf to http://localhost:12444  as that remote port appears to be a local port.   You do not connect to the.hosts.public.ip:12444.

I hope I explained that well.

edit: changed -D to -L in the ssh command.  Thanks to bulletmark and his post below

Last edited by ewaller (2014-08-16 23:28:54)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2014-08-16 23:12:42

bulletmark
Member
From: Brisbane, Australia
Registered: 2013-10-22
Posts: 683

Re: Remote SSH and Port Forwarding

ewaller wrote:

What I think you want to do is connect to  sshd on port 22 using the ssh  -D option to forward port 12444.   What happens is that sshd on the host then opens a connection to its own localhost:12444 and sends that information through the ssh connection on port 22.  At the client end, the ssh client opens a listener at its localhost:12444 and uses that as the endpoint for the data coming through the ssh pipe.  If your server on the host on port 12444 happened to serve up http stuff, one could run a browser on the client machine and surf to http://localhost:12444  as that remote port appears to be a local port.   You do not connect to the.hosts.public.ip:12444.

I hope I explained that well.

emaller, you hunch is probably correct and your description above is ok, except you have stated the wrong switch "-D" where I am sure you mean "-L". He likely wants to forward a local port (-L) as you say. He probably does not want to set up a dynamic socks proxy (-D).

Last edited by bulletmark (2014-08-16 23:13:32)

Offline

#6 2014-08-16 23:26:06

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,354

Re: Remote SSH and Port Forwarding

You are, of course, correct.  Posting in a hurry smile


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#7 2014-08-22 03:39:11

xworld
Member
Registered: 2012-05-27
Posts: 153

Re: Remote SSH and Port Forwarding

Yes the xx did represent octets in an IP address. Thanks for the responses. I will try what you recommended but I don't think it will matter what port I choose or what kind of configuring I do on the LAN end, because my router simply won't allow anything from the outside through, even if I specify. Even if I disable the firewall, and create a rule to open port 12444 or whatever I decide, it still acts as though it is firewalled. A scan from the outside shows everything as filtered.

Offline

#8 2014-09-12 00:05:27

xworld
Member
Registered: 2012-05-27
Posts: 153

Re: Remote SSH and Port Forwarding

ewaller wrote:

I think, but I am not certain, that you have an incorrect concept as to how this works.  If I may...

When you forward a port on ssh, you usually still connect to ssh on port 22.  I think you are trying to forward port 12444, which presumably has some custom server sitting on it on your host (A game, something you wrote, etc...).   If you can hit that port from your host at localhost:12444, or from your lan at your.private.ip.address:12444, then this is the case.

What I think you want to do is connect to  sshd on port 22 using the ssh  -L option to forward port 12444.   What happens is that sshd on the host then opens a connection to its own localhost:12444 and sends that information through the ssh connection on port 22.  At the client end, the ssh client opens a listener at its localhost:12444 and uses that as the endpoint for the data coming through the ssh pipe.  If your server on the host on port 12444 happened to serve up http stuff, one could run a browser on the client machine and surf to http://localhost:12444  as that remote port appears to be a local port.   You do not connect to the.hosts.public.ip:12444.

I hope I explained that well.

edit: changed -D to -L in the ssh command.  Thanks to bulletmark and his post below

Would this method work from outside my network? Say I have an SSH server on port 12444 in a NATed network, and I want to connect to it from outside the network?

Offline

#9 2014-09-12 00:20:48

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,697
Website

Re: Remote SSH and Port Forwarding

It's simple, ssh -p 12444 user@wanip

Make sure u have 12444 forwarding to the LAN ip and the firewall not blocking that.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#10 2014-09-15 08:45:08

HiImTye
Member
From: Halifax, NS, Canada
Registered: 2012-05-09
Posts: 1,072

Re: Remote SSH and Port Forwarding

be conscious of local firewalls also. did you set up, for instance, ufw or iptables to block unopened ports?

Offline

Board footer

Powered by FluxBB