If you enable SSH on your mac, you’ll notice that you can’t easily change the listening port. This means that if you leave your computer connected for any time to the Internet you’ll see all sorts of brute force login attempts in /var/log/system.log.
To change the default port (22) of SSH on a Mac it’s really pretty simple.
- Add a service with your new ports to the /etc/services file
secret-ssh 2222/tcp #secret SSH
- Replace the references to the ssh service in /System/Library/LaunchdDaemons
- Restart the SSH LaunchDaemon
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist && sudo launchctl load /System/Library/LaunchDaemons/ssh.plist