port from remote machine to local machine

1. execute tunneling command on local machine
ssh -nNT -R8081:localhost:8080 marcuschiu-php56.cloudatron.com

this will pipe everything from marcuschiu-php56.cloudatron.com:8081 to your local machine’s port 8080.

2. Test the tunneling

  • Open a new terminal and execute

    nc -l 8080

    this command will listen on port 8080

  • Open a new terminal and execute

    ssh marcuschiu-php56.cloudatron.com

    then in your remote machine execute

    echo “Hello World” | nc localhost 8081

    this will push “Hello World” into the localhost port 8081 which is your remote machine’s port 8081.

  • go back to the terminal where you executed ‘nc -l 8080’

    you should see “Hello world”