I made this tutorial using Mac Os X 10.6.8 (Snow Leopard).
In this example, let’s say you want to change the default port 22 to port 2222
- Open the terminal window
sudo nano /etc/services
- Enter the root password, it will open the ‘services’ file. Be careful to avoid modify anything else.
- Press CTRL+W and search “ssh”.
- You will find to lines assigned to port 22. Something like this:
ssh 22/udp # SSH Remote Login Protocol ssh 22/tcp # SSH Remote Login Protocol
Change the number 22 in both cases to 2222 or whaterver the port you want to use. Press CTRL+X and then enter ‘Y’ to accept saving the file.
- Now we need to restart SSH. Enter the following command to stop it:
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
- Now enter the following command to start SSH again:
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
- That’s it, you must be ready to go. You can verify if is working by trying to access locally, just enter:
ssh localhost -p 2222