1

I have a Linux router(not used as DHCP/DNS server, simply a linux box on the network) at home that I want to use as my "remote access" device. My initial goal is to use SSH Tunneling to remotely access my network. For example, I can go to my (main) router's homepage from a remote location, simply from my web browser. However, I am not sure as to what SSH commands I need to run, and from where.

I can remotely execute SSH scripts from the Linux router. So creating tunnels at the remote location is not an issue. So, I can create a tunnel from a remote location to my local machine, but where do I go from there to access other parts of my network?

1
ssh -p 22 -i /home/path_to_privkey -L 12666:localhost:80 -l username xx.xxx.xxx.xxx

This command connects you to xx.xxx.xxx.xxx server, and binds your local port 12666 to the remote localhost port 80. So, if you type http://locahost:12666 in your browser, the result should be the same as opening http://localhost:80 on the remote (xx.xxx.xxx.xxx) machine. Changing the 80 to any other remote port, allows you to access (almost) any other remote service. Keep in mind, the tunnel exists only as long as the ssh connection.

For a full access, I would suggest setting up a VPN connection.

| improve this answer | |
  • Perfect! A VPN solution was my go-to, but far too time consuming at this point in time. A follow up question, would SSH tunnel to port 3389 (remote desktop) work as "effortlessly"? Thanks – Dark Mar 29 '17 at 4:35
  • Yes, this should work with remote desktop. Just try out. Problem is, if a service requires more ports to work (ftp, samba?). A time ago, I've setup a vpn "from scratch" based on openvpn to one of my servers working in DMZ (no real public IP) and the effort is really worth. Saves a lot time in the future. – psad Mar 29 '17 at 9:53
  • If you have a "spare" server there, you can try setting up a vpn with one from turnkeylinux.org. You will find there ready-to-go images of several servers. Try OpenVPN or pfSense. It takes some time to setup, but you will have a real vpn with full access. – psad Mar 29 '17 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.