1. Change port accordingly:
port: sudo vi /private/etc/ssh/sshd_config
ssh: sudo vi /etc/services
2. Relaunch ssh
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
3. Check the port
ssh localhost -p ###port.number.here###
4. add XAuthLocation
For the client, modify .ssh/config as follows,
XAuthLocation ###your.xauth.path###
For the server, modify /private/etc/ssh/sshd_config and /etc/ssh/sshd_config
XAuthLocation ###your.xauth.path###
, where you can check the path of xauth by following command:
which xauth