SSH port forwarding

I always forgetting it, and spend alot of time to find the solution in google and browsers history. Now i write it here to simplify my life and speedup the progress.

To make SSH as socks proxy
$ ssh -D 5000 -N theservername

Example :

$ ssh -D 5000 -N 10.1.10.10

now, configure your global OS proxy or browser proxy to localhost port 5000 and check your public IP from http://ifconfig.me/ip it shall return your ssh machine public IP.

Only forward some port to your local port
$ ssh -L 3000:google.com:80 user@proxy

Example :

$ ssh -L 3000:google.com:80 user@10.1.10.10

Now, we can reach google.com from localhost:3000. Those command will also logging you in there. Use parameter -N after ssh to only tunneling without logging in.

I got this from Security stackexchange and Ubuntu documentation

Comments