Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have multiple machines on my network that I access regularly using ssh. I want to enable remote access through port forwarding, which means I'll need separate sshd ports for each machine. That said, I'd like to continue to use port 22 for local access.

I realize that I have to add the configs to /etc/services and that the key to my answer lies in sshd.plist. I've attempted to follow various suggestions online, all of which seem to indicate that the plist files exist in different locations than mine do. One suggested ssh.plist and another sshd.plist. My changes to ssh.plist accomplished nothing. Another suggested changing sshd.plist, which didn't even exist on my machine, but /System/Library/LaunchDaemons/ does. I was going to make and rename a copy of that file, but I couldn't tie it to a call in /etc/services. I made a copy anyway, but then I couldn't figure out how to modify the key as it's current value had no relationship to the file name (unlike the example for ssh.plist).

So, I currently have ssh and ssh-alt set in services, two ssh.plist files that vary based on the different file names (one ssh and the other ssh-alt) and two .sshd.plist files that are mirror images of each other. When I rebooted the machine, port 22 no longer works, but my alternate port does.

Any suggestions would be appreciated.

share|improve this question
This Q/A might be what you need - let us know if your issue is different than the other. – bmike Feb 20 '13 at 4:09
Thanks, but that was the first one I followed without success. I chalked that failure up to it being an older version of OS X (lion not mountain lion). Note that he refers to ssh.plist and not sshd.plist – user2000664 Feb 21 '13 at 0:48
Rather than adjusting the machines, can you adjust your router to forward different ports externally to the proper machine at port 22? This may be a more sustainable solution if you have a router that supports this... – Scot Sep 14 '13 at 4:49

Welp, I found the answer after a few more days of research, with the help of a response to this MacWorld post I thought there had to be some way to include multiple ports in the one .plist file, but I couldn't figure it out. You can add an "Alternate Listener" key to ssh.plist for the extra port inside the Sockets scope, such as:

         <key>Alternate Listeners</key>

Notice the ssh-alt string for SockServiceName. The original "Listeners" key remains as is, so you have Listeners and Alternate Listeners. You have two entries in /etc/services for ssh and ssh-alt like:

ssh              22/udp
ssh              22/tcp
ssh-alt        4790/udp
ssh-alt        4790/tcp

which preserves the port 22 internal access and creates access via port 4790 for external use (assuming you disable port 22 and port forward port 4790 on your firewall/router.

share|improve this answer
Unless you need to use the "ssh-alt" definition somewhere else, I find it easier to put the port number in the ssh.plist directly and don't bother editing the /etc/services file. (E.g. change <string>ssh-alt</string> to <string>4790</string>.) Also, "Alternate Listeners" can be any label you want (e.g. "External"). – ithos67 Jan 22 '14 at 4:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.