Last Updated: February 25, 2016
·
1.282K
· sheerun

Forward port from active ssh connection

Say, you've installed pup, and it's listening on 17125 port, on loopback interface (so you can only access it from machine, not the Internet).

You can forward pup port to your local machine, so it can be viewed from your browser by typing http://localhost:17125 by typing

ssh server@example.com -NL 17125:localhost:12125 

HOWEVER, if your ssh connection is already opened, you can type:

~C

That is tilde and capital C, to access ssh console. Now, you can type:

-L 17125:localhost:12125

And set your local forward on the fly.

Bonus: you can set up your port forwarding automatically, every time you connect, by using ssh config file.