12

I'm trying to use an ssh tunnel from a remote location to connect to my home network and access the router web interface.

I have SSH access to the home network, and I can connect to the gateway machine "Lounge". (e.g. 192.168.1.100)

What would I need to do to proxy web requests to the router (192.168.1.1) on the home network, via "Lounge", so that I can view it from the remote location?

If it makes a difference, the "Lounge" machine is running OS X.

I want an ssh / command-line only solution to this, thanks.

2 Answers 2

19

ssh command...

ssh user@remotehost -L localport:host_reachable_from_remote_host:remoteport

So for example...

ssh [email protected] -L 8080:192.168.1.1:8080

This will create a tunnel to 192.168.1.1 port 8080 on the remote network (reachable from the machine at 100.100.100.100), to the local port 8080.

Viewable via http://localhost:8080 in your browser.

If you want to avoid having ssh open the shell connection on the remote machine, and just leave the tunnel open, use the switch -N for example.

ssh -N [email protected] -L 8080:192.168.1.1:8080
4
  • The command is good, but modern routers check something that results in 403 access denied. Perhaps it checks origin?
    – Redsandro
    Apr 1, 2021 at 20:33
  • @Redsandro - depends on the vendor. I just used this tunnel method to jump on my (2 yr old) home router, and there were no issues.
    – ocodo
    Jun 1, 2022 at 17:34
  • I made this the accepted answer, because the question is for ssh, not puTTY.
    – ocodo
    Jun 1, 2022 at 17:36
  • "Your request has bad syntax or is inherently impossible to satisfy."
    – Advanced
    Dec 26, 2022 at 22:04
11

Download putty if you don't already have it, the format you need for this is:

putty -ssh username@publicip -pw password -L localport:privateip:destinationport

Here is what you would use to get to 192.168.1.1 remotely through SSH:

putty -ssh username@publicip -pw password -L 8080:192.168.1.1:80

You could then open up a web browser to 127.0.0.1:8080 on the computer you created the tunnel with and up would pop the router interface.

2
  • 1
    putty is cross platform, I have done this from a linux box as well as from a windows box, and I have done it through many operating systems. The operating system should not matter on the SSH server or on the client you are using to connect.
    – MaQleod
    Aug 31, 2011 at 6:27
  • If I do that, I get redirected to the router page of my current network (Not the remote one). If I do it with every other webpage, it works. Any solution? Oct 8, 2019 at 13:54

You must log in to answer this question.

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