AuthorizedKeysCommand is ignored
House Lee
hlee at vendasta.com
Fri Dec 22 04:51:27 AEDT 2017
Hi All,
I tried build openssh from source code on Alpine Linux. The AuthorizedKeysCommand is not working. Using .ssh/authorized_keys to auth the user is fine. The ‘AuthorizedKeysCommand’ is never called. However, if I install the openssh by ‘apk add openssh’, everything including the AuthorizedKeysCommand works just fine.
Steps taken:
1. autoconf && autoheader
2. ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords
3. make && make install
And I have the sshd_config like the following:
LogLevel DEBUG
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
SyslogFacility AUTHPRIV
PermitRootLogin no
StrictModes yes
MaxAuthTries 3
PubkeyAuthentication yes
AuthorizedKeysCommand /usr/bin/sftp-getkey %u %f
AuthorizedKeysCommandUser nobody
PasswordAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
X11Forwarding no
ClientAliveInterval 420
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
Subsystem sftp internal-sftp
Match User 10390
ChrootDirectory /mnt/user-10390
AllowTCPForwarding no
X11Forwarding no
ForceCommand internal-sftp
Everything seems fine, however, the sshd kept ignored AuthorizedKeysCommand when the user is trying to login. It keeps falling back to '/home/10390/.ssh/authorized_keys’
Any ideas why?
Thanks & Best Regards,
House
Here’s the detail of the log
Connection from 10.240.2.252 port 52275 on 10.156.4.130 port 22
debug1: Client protocol version 2.0; client software version OpenSSH_7.6
debug1: match: OpenSSH_7.6 pat OpenSSH* compat 0x04000000
debug1: Local version string SSH-2.0-OpenSSH_7.6
debug1: permanently_set_uid: 22/22 [preauth]
debug1: list_hostkey_types: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
debug1: SSH2_MSG_KEXINIT sent [preauth]
debug1: SSH2_MSG_KEXINIT received [preauth]
debug1: kex: algorithm: curve25519-sha256 [preauth]
debug1: kex: host key algorithm: ecdsa-sha2-nistp256 [preauth]
debug1: kex: client->server cipher: chacha20-poly1305 at openssh.com MAC: <implicit> compression: none [preauth]
debug1: kex: server->client cipher: chacha20-poly1305 at openssh.com MAC: <implicit> compression: none [preauth]
debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]
debug1: rekey after 134217728 blocks [preauth]
debug1: SSH2_MSG_NEWKEYS sent [preauth]
debug1: expecting SSH2_MSG_NEWKEYS [preauth]
debug1: SSH2_MSG_NEWKEYS received [preauth]
debug1: rekey after 134217728 blocks [preauth]
debug1: KEX done [preauth]
debug1: userauth-request for user 10390 service ssh-connection method none [preauth]
debug1: attempt 0 failures 0 [preauth]
debug1: user 10390 matched 'User 10390' at line 43
debug1: userauth-request for user 10390 service ssh-connection method publickey [preauth]
debug1: attempt 1 failures 0 [preauth]
debug1: temporarily_use_uid: 0/0 (e=0/0)
debug1: restore_uid: 0/0
debug1: temporarily_use_uid: 0/0 (e=0/0)
debug1: restore_uid: 0/0
debug1: temporarily_use_uid: 10390/1000 (e=0/0)
debug1: trying public key file /home/10390/.ssh/authorized_keys
debug1: fd 4 clearing O_NONBLOCK
debug1: restore_uid: 0/0
debug1: temporarily_use_uid: 10390/1000 (e=0/0)
debug1: trying public key file /home/10390/.ssh/authorized_keys2
debug1: Could not open authorized keys '/home/10390/.ssh/authorized_keys2': No such file or directory
debug1: restore_uid: 0/0
Failed publickey for 10390 from 10.240.2.252 port 52275 ssh2: RSA SHA256:mUPB/sDD50ZizduqE636LK77NKEWNbHqN6B4tjInWQU
Connection closed by authenticating user 10390 10.240.2.252 port 52275 [preauth]
More information about the openssh-unix-dev
mailing list