7

I have enabled remote login (ssh) on my Mac via System Preferences. But it doesn't work with keys and only works with normal user/pass authentication. I want to disable this behaviour and only allow public key (RSA or DSA) authentication.

I edited /etc/sshd_config and uncommented following lines:

PasswordAuthentication no
PermitEmptyPasswords no

I then restarted the Remote Login service but it didn't help. It still allows password authentication and my keys are rejected.

Could anyone help me set this up?

5
  • 1
    Please split of the second part (local network only) into a separate question, makes it easier for people to answer just one of them. – nohillside Dec 18 '11 at 19:58
  • Done - apple.stackexchange.com/questions/34091/… – Michal M Dec 18 '11 at 20:18
  • Where and how do you define your authorized keys? Key bases login works fine out of the box. – Gerry Dec 18 '11 at 20:30
  • @Gerry I have had my personal private/public keys generated for a while now. I used cat id_rsa.pub >> ~/.ssh/authorized_keys, but no success. – Michal M Dec 18 '11 at 20:35
  • Did you fiddle with any other sshd settings before? A print out of your sshd_config file could be useful. If not, my guess is your public key is invalid, or does not match your private key, maybe you should try to generate a new key. – Gerry Dec 18 '11 at 21:21
6

Allow me to answer myself as I found a resolution.

If PasswordAuthentication no doesn't work on its own (and I read in some situations it may) make sure to uncomment and set to "no" this:

UsePAM no

Kudos for this resolution go to Mac OS X Hints - http://hints.macworld.com/article.php?story=20050815135941513&lsrc=osxh.

1
  • On OS X El Capitan 10.11.2 the file to edit is /private/etc/ssh/sshd_config – jonatan Feb 28 '16 at 17:24
0

On Mac OS X 10.8.5 (Mountain Lion) you also need to comment out the following line in /etc/sshd_config:

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
#AuthorizedKeysFile     .ssh/authorized_keys

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .