Setup on macOS based client

Copy your public key to the server

ssh-copy-id -i ~/.ssh/[your_public_key] [user]@[host_name] -p [port]

Connect to the server

ssh [user]@[host_name] -p [port]

Create a new host to connect easily

Host [alias]
  User [user]
  HostName [host_name]
  Port [port]
  IdentityFile ~/.ssh/[your_private_key]

Setup on macOS based server

Start/stop SSH

sudo systemsetup -setremotelogin on
sudo systemsetup -setremotelogin off

Disable password authentication

PasswordAuthentication no
KbdInteractiveAuthentication no
UsePAM no

Restart SSH daemon

sudo launchctl stop com.openssh.sshd
sudo launchctl start com.openssh.sshd