Web Proxy

Using for forward a web browser like a proxy:

With the -D flag. For example:

 ssh -D 12345 myuser@remote_ssh_server 

will open up the port 12345 on your local machine as a SOCKS proxy so all your HTTP traffic can be specified to go through the SSH tunnel and out remote_ssh_server on the other end.

Next, set up your browser to use the proxy server. Most browsers include proxy support. For Firefox: Edit - Preferences - Advanced - Network Settings, and specify that you want to use a Manual Proxy → localhost, port 12345 and SOCKS v5 (or 4)

Done!

Port redirect

All with -L flag: ssh -L LPORT:localhost:RPORT user@ip

LPORT: Local port that will be listening (mapping)

RPORT: Port from server site (port you want to map)

For example:

ssh -L 1521:localhost:1521 root@oracleserver

This will allow to connect to a oracle database that have a ssh running server. Just point your computer to connect to localhost after running this command.

Port redirect to another computer on remote lan

Just like before but the localhost is replaced by the ip from the lan you need to point at. This is very useful to use a ssh server like a VPN server. You will have to change the port and the remote ip.

Like the above example, let's use a ssh server accessible from Internet, to access to a database server inside remote lan.

ssh -L 1521:oracleserverinternalip:1521 user@remote-ssh-server

But now, the remote-ssh-server will map the oracle port, so you will access to oracle using remote-ssh-ip and 1521 port.

Enter your comment. Wiki syntax is allowed:
 
  • daily/ssh_port_forwarding.txt
  • Last modified: 2019/04/10 11:54
  • by admin