OpenSSH Server Not Reading authorized_keys

Asked by Dagan Henderson

I've got a completely fresh install of Ubuntu 12.04 and installed OpenSSH as part of the OS installation. SSH is working, but not with public key authentication.

I've verified that the file permissions are correct (several times), but running a stat on authorized_keys shows that sshd is never reading the file. I've also turned strictmodes off as a diagnostic step, but that didn't solve anything either.

stat output:

File: `.ssh/authorized_keys'
Size: 397 Blocks: 8 IO Block: 4096 regular file
Device: fc00h/64512d Inode: 5898265 Links: 1
Access: (0600/-rw-------) Uid: ( 1000/ dagan) Gid: ( 1000/ dagan)
Access: 2012-05-12 13:43:09.347773631 -0700
Modify: 2012-05-12 13:42:46.519772851 -0700
Change: 2012-05-12 13:42:46.523772828 -0700

Here are my config file and a debug log:
================================

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel DEBUG

# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes no

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

DEBUG LOG:
--------------

May 13 12:48:59 gemma sshd[23242]: Set /proc/self/oom_score_adj from 0 to -1000
May 13 12:48:59 gemma sshd[23242]: debug1: Bind to port 22 on 0.0.0.0.
May 13 12:48:59 gemma sshd[23242]: Server listening on 0.0.0.0 port 22.
May 13 12:49:08 gemma sshd[23242]: debug1: Forked child 23243.
May 13 12:49:08 gemma sshd[23243]: Set /proc/self/oom_score_adj to 0
May 13 12:49:08 gemma sshd[23243]: debug1: rexec start in 4 out 4 newsock 4 pipe 6 sock 7
May 13 12:49:08 gemma sshd[23243]: debug1: inetd sockets after dupping: 3, 3
May 13 12:49:08 gemma sshd[23243]: Connection from 10.0.0.102 port 57593
May 13 12:49:08 gemma sshd[23243]: debug1: Client protocol version 2.0; client software version PuTTY_Release_0.62
May 13 12:49:08 gemma sshd[23243]: debug1: no match: PuTTY_Release_0.62
May 13 12:49:08 gemma sshd[23243]: debug1: Enabling compatibility mode for protocol 2.0
May 13 12:49:08 gemma sshd[23243]: debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
May 13 12:49:08 gemma sshd[23243]: debug1: permanently_set_uid: 112/65534 [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: list_hostkey_types: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256 [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: SSH2_MSG_KEXINIT sent [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: SSH2_MSG_KEXINIT received [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: kex: client->server aes256-ctr hmac-sha1 none [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: kex: server->client aes256-ctr hmac-sha1 none [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: SSH2_MSG_KEX_DH_GEX_REQUEST_OLD received [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: SSH2_MSG_KEX_DH_GEX_GROUP sent [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: expecting SSH2_MSG_KEX_DH_GEX_INIT [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: SSH2_MSG_KEX_DH_GEX_REPLY sent [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: SSH2_MSG_NEWKEYS sent [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: expecting SSH2_MSG_NEWKEYS [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: SSH2_MSG_NEWKEYS received [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: KEX done [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: userauth-request for user dagan service ssh-connection method none [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: attempt 0 failures 0 [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: PAM: initializing for "dagan"
May 13 12:49:08 gemma sshd[23243]: debug1: PAM: setting PAM_RHOST to "dagan"
May 13 12:49:08 gemma sshd[23243]: debug1: PAM: setting PAM_TTY to "ssh"
May 13 12:49:08 gemma sshd[23243]: debug1: userauth-request for user dagan service ssh-connection method publickey [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: attempt 1 failures 0 [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: test whether pkalg/pkblob are acceptable [preauth]
May 13 12:49:08 gemma sshd[23243]: debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
May 13 12:49:08 gemma sshd[23243]: debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
May 13 12:49:08 gemma sshd[23243]: debug1: temporarily_use_uid: 1000/1000 (e=0/0)
May 13 12:49:08 gemma sshd[23243]: debug1: trying public key file /home/dagan/.ssh/authorized_keys
May 13 12:49:08 gemma sshd[23243]: debug1: fd 4 clearing O_NONBLOCK
May 13 12:49:08 gemma sshd[23243]: debug1: restore_uid: 0/0
May 13 12:49:08 gemma sshd[23243]: Failed publickey for dagan from 10.0.0.102 port 57593 ssh2
May 13 12:49:11 gemma sshd[23243]: debug1: userauth-request for user dagan service ssh-connection method password [preauth]
May 13 12:49:11 gemma sshd[23243]: debug1: attempt 2 failures 1 [preauth]
May 13 12:49:11 gemma sshd[23243]: debug1: PAM: password authentication accepted for dagan
May 13 12:49:11 gemma sshd[23243]: debug1: do_pam_account: called
May 13 12:49:11 gemma sshd[23243]: Accepted password for dagan from 10.0.0.102 port 57593 ssh2

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu openssh Edit question
Assignee:
No assignee Edit question
Solved by:
Dagan Henderson
Solved:
Last query:
Last reply:
Revision history for this message
Dagan Henderson (dagan) said :
#1

[Solved]
Embarrassingly, it was a problem with the public key. Although I had copy-and-pasted it, one character had been trimmed.

For me, the answer was revealed by launch sshd in triple-debug mode (sudo /usr/sbin/sshd -d -d -d).