How to change the default SSH port in Mac OS X (+10.5)

This will explain how to change the default SSH port in Mac OS X from 22 to something else.

This drastically reduces the risk of intrusion.

There are different ways to do this, but this is the most convenient way in my opinion.

1. Open up a terminal and enter

sudo pico /etc/services

Enter your password.

2. Scroll down to the very bottom and add the following line:

secret-ssh      12345/tcp    # secret SSH port

Replace 12345 with your desired port number, making sure that it doesn’t interfere with anything else running on your system.

3. Press CTRL-X and confirm by pressing Y and enter to save the file.

4. Now we need to modify /System/Library/LaunchDaemons/ssh.plist.

Again in the terminal, enter:

sudo pico /System/Library/LaunchDaemons/ssh.plist

Locate the following:

<key>SockServiceName<key>
<string>ssh</string>

Replace ssh with secret-ssh.

Save and exit as before.

5. Enter the following commands or reboot your machine to make the changes take effect:

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

6. You’re done!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s