Many years ago, I needed to change the port that sshd listens on on my Mac. Which I managed at the time, but I don’t remember how I did it.
As is usually the case, I “hit up” Google (as the kidz are wont to say, I think) and after a bit of trawling I found the solution:
- Open Terminal and as edit the file /etc/services (as root)
- Add a line at the bottom:
secret-ssh 43539/tcp # secret SSH port
- Edit file
/System/Library/LaunchDaemons/ssh.plist
and replace the code:<key>SockServiceName </key> <string>ssh </string>
with
<key>SockServiceName </key> <string>secret-ssh </string>
- Change your port forwarding configuration on your firewall to route port 43539 instead
- Open “Sharing” control panel and ensure that “Remote Login” is checked off (if not uncheck it). Then check it again to start with the new configuration.
I got this information from this page here, and, if you look in the comments there, you’ll see it’s the exact page I’d come across originally. Here lies a lesson: bookmarks!
I don’t know Macs, but that’s more different to Linux than I’d expected.
Do you not have an /etc/ssh/sshd_config in Macs then?
Yes. There is more than one way of doing it – the “proper” Mac way is using modified or created LaunchDaemons, but you can do it the linuxy way too.