∅ the empty set

How to change the default sshd port on Mac OS X

I've been subjected to an interrupted stream of failed login attempts on port 22 (sshd) this last week that are clogging up my log files.

Turning off sshd (a.k.a. Remote Login) altogether was a half backed option as I connect remotely to my workstation, so I decided to change the default sshd port to wave off the bulk of repeated login attempts.

Editing the ssh.plist preference file

  1. Turn off Remote login in the Sharing Preference pane
  2. Open the Terminal (/Applications/Utilities/Terminal)
  3. Navigate to /System/Library/LaunchDaemons/
  4. Make a backup copy of ssh.plist
  5. Edit ssh.plist and replace the service name (ssh) with the port you wish to use (e.g. 22091)
  6. Save the changes and turn Remote login back on in the Sharing Preference pane (which restarts the ssh service with launchctl)
  7. Test your connection in the Terminal ssh yourusername@yourdomain.com -p 22091 (use the port number you chose).

The following 2 occurences were changed:

[…]
<key>Sockets</key>
<dict>
  <key>Listeners</key>
  <dict>
    <key>SockServiceName</key>
    <string>22091</string>
    <key>Bonjour</key>
    <array>
        <string>22091</string>
        <string>sftp-ssh</string>
    </array>
  </dict>
</dict>
[…]

You can find more information on launchd handled services on Mac OS X in the launchd.plist(5) manual.

Ø permalink: https://davidroessli.com/logs/2012/10/how_to_change_the_default_sshd/


Reponses to “How to change the default sshd port on Mac OS X”

#1 by Adam P

17:15 on 24 May 2015

Thanks for posting this. Worked like a charm!

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)



Previous: Smashing Title

Next: Why my border-image didn't display in Firefox 15


About

Hello, my name is David Roessli. I am a freelance web designer and developer based in Geneva, Switzerland.

This weblog is an nth attempt to solve my multiple online personalities and weblog/rss feeds burnout issues. (more)

Words

I have been contemplating the idea of upgrading my desktop Mac since this spring. The latest 27" iMac (Quad-Core) seemed the perfect candidate, but the release of Apple's 27" Monitor last September made me stick with the Mac Pro...

Music

The autopsy of an iconic album cover picked up on Kottke.org. A stacked graph of successive radio signals from pulsar CP 1919, in a 1977 astronomy encyclopedia that originated in a 1970 Ph.D. thesis. Fascinating <3...

Pictures

Check out my latest Flickr ramblings. Mostly day to day cameraphone pictures stolen here and there.


© 2000-2016 David Roessli | v4.1 | as valid xhtml and css as possible | hosted by pair Networks | RSS feeds.