From the Terminal

Port forwarding with SSH Tunneling

With OpenSSH, port forwarding is configured using the -L option.

You can initiate a port forwarding operation with this command:

ssh -L

In this example we are telling OpenSSH to open port 80 on the current machine to on port 80 from the server we are connecting to. In this case the server is

Don't forget that anyone can connect to this port on your machine so you might want to limit connects to localhost by telling OpenSSH to listen on a specific IP. In this case you can specify like so:

ssh -L

Since this is OpenSSH you can actually use the alias you specified in your ~/.ssh/config file.

I talk more about the OpenSSH config file here.

Building on top of that guide if you want to maintain a port forward everytime you connect to a specific machine you can use this syntax:

Host alias
	User user
	IdentityFile /Users/user/.ssh/mykey_rsa

Now you can simply type in ssh alias in terminal and be connected with a port forward.