Change the SSHd port on Mac OS X

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.

  1. Add a service with your new ports to the /etc/services file

    secret-ssh 2222/tcp #secret SSH

  2. Replace the references to the ssh service in /System/Library/LaunchdDaemons
  3. Restart the SSH LaunchDaemon

    sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist && sudo launchctl load /System/Library/LaunchDaemons/ssh.plist

Leave a Reply

There aren't any comments at the moment, be the first to start the discussion!