Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

To disable password auth I've set the following values in my sshd_config

ChallengeResponseAuthentication no
PasswordAuthentication no
UsePAM no

When I try to log in with my private key I get

Permission denied (publickey).

If I then change UsePAM to yes I can login using my private key. Why?

I'm connecting to a Ubuntu 12.04 64bit host from OSX

ssh -i ~/.ssh/deploy -l deploy localhost -p 2222 -v

here's the verbose ssh output:

OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /Users/<user>/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 2222.
debug1: Connection established.
debug1: identity file /Users/<user>/.ssh/deploy type 1
debug1: identity file /Users/<user>/.ssh/deploy-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 50:db:75:ba:11:2f:43:c9:ab:14:40:6d:7f:a1:ee:e3
debug1: Host '[localhost]:2222' is known and matches the RSA host key.
debug1: Found key in /Users/<user>/.ssh/known_hosts:2
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/<user>/.ssh/key1
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: /Users/<user>/.ssh/deploy
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
share|improve this question
    
Did you run sshd in debug mode and check the log it generates? –  Michael Hampton Feb 6 '13 at 2:18
    
We're definitely going to need more logs. I replicated your situation in a VM (using Fedora 17) and it worked for me. –  Scott Pack Feb 6 '13 at 2:40

1 Answer 1

up vote 3 down vote accepted

Without PAM (Pluggable Authentication Module) more complicated ssh configuration is required to authenticate. You're looking for this, actually:

# grep Password /etc/ssh/sshd_config 
PermitEmptyPasswords no
PasswordAuthentication no

This will disable passworded login. Ensure you public key settings correctly established.

share|improve this answer
    
This isn't really true. In fact, many guides recommend setting ChallengeResponseAuthentication, PasswordAuthentication, and UsePAM all to no and using only public key authentication. I've never worked in such an environment, so I can't easily give a real reason why it's not working quite yet. –  Scott Pack Feb 6 '13 at 2:27
1  
Thats why I set it to no in the first place, because every guide I found did it! –  Erik Aigner Feb 6 '13 at 2:30
    
I'll stand corrected; you're correct, Scott. That said, if he doesn't wish to use pam_unix, he'll need to configure pam_nologin (or allow root access.) www-uxsup.csx.cam.ac.uk/pub/doc/suse/sles9/adminguide-sles9/… –  Stephan Feb 6 '13 at 2:36

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.