In my Windows system, I was able to create a tunnel by running the command below using Putty:

putty.exe -D 12345 -P 8888 localhost

I'm not used to Mac yet and I would like to try it out on Mac. Does anyone know the command to achieve same tunneling in Mac OS X or do I have to use a client?

  • What are you trying to accomplish? I don't know putty command line options, so I'm not sure what traffic you're actually trying to forward, and in which direction.
    – cjc
    Feb 4, 2012 at 14:09

4 Answers 4


putty's command-line options are (mostly, but not entirely) a clone of those that the openssh client uses, so the equivalent of your command line above would just be ssh -D 12345 -p 8888 localhost.

Read man ssh for the full details of the options.

Well. I don't know why you'd forward ports to localhost, but I'm sure that was just a demo ;)

  • Thx James. I will try your answer out. :)) . As to why I would ports to localhost, it is needed for bypassing stubborn firewalls.
    – Martin
    Feb 4, 2012 at 7:57
  • UPDATE: I just tried it but it failed, it appears an attempt was made to connect Host 8888 on port 22 which is wrong. ........................ ssh -D 12345 -P 8888 localhost ssh: connect to host 8888 port 22: Network is unreachable
    – Martin
    Feb 4, 2012 at 8:04
  • Hah. I missed that. it'll be -p 8888 rather than -P 8888 :) Feb 4, 2012 at 8:57

MacOSX provide by default a command-line ssh client, just execute it from a terminal with:

$ ssh user@hostname

To check that options are the same that you are accustomed with PuTTY, read the ssh man reference with:

$ man ssh

Mac's ssh syntax (and for most other *nix commands) is not the same as in a Linux box. I think you could try ssh -D 12345 -p 8888 localhost, but I don't remember quite well. The best way is man ssh.

I usually make a config file (.ssh/config) with parameters so that you can simply type ssh bypassfw if you want to run that command.

Host bypassfw
HostName localhost
Port 8888
DynamicForward 12345
  • Thx for the suggestion. Just tried it but it failed.
    – Martin
    Feb 4, 2012 at 8:44
  • I forgot "localhost" in the command. I also added a .ssh/config file, the method which I used when I was on Mac. However, did you try man ssh?
    – jcisio
    Feb 4, 2012 at 8:46
  • Did'nt work out :((
    – Martin
    Feb 4, 2012 at 9:43

Not sure if this is still relevant or not. But I used this command.

ssh -L 8080: remote_user@


ssh -L local_port:remote_ip:remote_port remote_user@remote_ip

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy