Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

share|improve this question
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. –  patrix 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
show 1 more comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.