Disable ssh password authentication on High Sierra

high sierrassh

I want to disable password auth – ie keys only – on SSH. I've done this many times on Linux variants, and some searching here suggests it's the same on Mac, ie:

/etc/ssh/sshd_config

Then add/edit:

PasswordAuthentication no

However, this seems to have no effect – ie I can still log in with a password. Is there any different trick to do this on High Sierra?

Best Answer

For High Sierra, to prevent authentication without publickey, in the /etc/ssh/sshd_config file, set

PasswordAuthentication no
UsePAM no

To restart sshd (which is required to have it reread the config file), use

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