Skip to content

Local Port Fwding

SSH Local Port FWDing

Scenario

  • Your PWNBox has a connection to an Ubuntu server
  • The ubuntu server has a MySQL port 3306 open on its localhost and not to the public.
  • We can forward our local port 1234 to remote port 3306 to access Ubuntu's MySQL listener on its localhost interface.
  • SSH can listen on our local host and forward a service on the remote host to our port.
  • Redirect a local port to a port on the remote host through SSH.
  • Access remote services on our local host.

Workflow:

  • forward our local port (1234) over SSH to the Ubuntu server.
    • ssh -L 1234:localhost:3306 ubuntu@10.129.203.10
      • -L : tell the SSH client to request the SSH server to forward all the data we send via port 1234 to localhost:3306 on the Ubuntu server
    • Now, we will be able to access MySQL on 1234 locally on the PWNBox
  • Confirm port forwarding:
    • netstat -tanp | grep 1234
    • netstat -tunlp | grep 1234
    • nmap -v -sV -p1234 localhost
  • Forwarding multiple ports locally
    • ssh -L 1234:localhost:3306 -L 8080:localhost:80 ubuntu@10.129.202.64