I have read numerous solutions to this problem, but none seem to apply to what I'm seeing. Most focus on directory permissions, but those appear to be correct in this case. TL;DR: Two Centos7 servers with the same home directory; one's sshd is not allowing publickey authentication even though it is enabled.
I have two centos7 servers, let's call them centos-a and centos-b. Home directories are mounted via NFS, so the .ssh directories are identical between both (confirmation of this below). I can ssh from centos-a to centos-a, but not to centos-b. I can ssh from centos-b to centos-a and to centos-b.
| ssh-ability | centos-a | centos-b |
|---|---|---|
centos-a | YES | NO |
centos-b | YES | YES |
[myuser@centos-a ~]$ ls -la ~/.ssh total 16 drwx------. 1 myuser domain users 0 Jul 6 11:45 . drwx------. 1 myuser domain users 0 Jul 7 13:44 .. -rw-------. 1 myuser domain users 1212 Jul 6 12:02 authorized_keys -rw-------. 1 myuser domain users 1675 Jul 6 11:45 id_rsa -rw-r--r--. 1 myuser domain users 402 Jul 6 11:45 id_rsa.pub -rw-r--r--. 1 myuser domain users 1119 Jul 6 17:49 known_hosts [myuser@centos-a ~]$ md5sum ~/.ssh/* 65b4fdf2d59cee3ae45b8480454453ec /home/myuser/.ssh/authorized_keys fa3e9fc5a8ff08787ff2ba8f979da24e /home/myuser/.ssh/id_rsa dca36ab3ec342423c5eca588f2ad5678 /home/myuser/.ssh/id_rsa.pub f67bc94bc7a30b9876e3027b24f893d8 /home/myuser/.ssh/known_hosts [myuser@centos-a ~]$ ssh centos-a hostname centos-a [myuser@centos-a ~]$ ssh centos-b hostname myuser@centos-b's password: [myuser@centos-b ~]$ ls -la ~/.ssh total 16 drwx------. 1 myser domain users 0 Jul 6 11:45 . drwx------. 1 myser domain users 0 Jul 7 13:44 .. -rw-------. 1 myser domain users 1212 Jul 6 12:02 authorized_keys -rw-------. 1 myser domain users 1675 Jul 6 11:45 id_rsa -rw-r--r--. 1 myser domain users 402 Jul 6 11:45 id_rsa.pub -rw-r--r--. 1 myser domain users 1119 Jul 6 17:49 known_hosts [myuser@centos-b ~]$ md5sum ~/.ssh/* 65b4fdf2d59cee3ae45b8480454453ec /home/myuser/.ssh/authorized_keys fa3e9fc5a8ff08787ff2ba8f979da24e /home/myuser/.ssh/id_rsa dca36ab3ec342423c5eca588f2ad5678 /home/myuser/.ssh/id_rsa.pub f67bc94bc7a30b9876e3027b24f893d8 /home/myuser/.ssh/known_hosts [myuser@centos-b ~]$ ssh centos-b hostname centos-b [myuser@centos-b ~]$ ssh centos-a hostname centos-a As shown above, the permissions on the .ssh directory appears to be correct (and, regardless, is identical between both machines).
ssh -vvv on the failing ssh shows:
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017 ... debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4 debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000 ... debug1: Host 'centos-b' is known and matches the ECDSA host key. ... debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password debug3: authmethod_lookup gssapi-keyex debug3: remaining preferred: gssapi-with-mic,publickey,keyboard-interactive,password debug3: authmethod_is_enabled gssapi-keyex debug1: Next authentication method: gssapi-keyex debug1: No valid Key exchange context debug2: we did not send a packet, disable method debug3: authmethod_lookup gssapi-with-mic debug3: remaining preferred: publickey,keyboard-interactive,password debug3: authmethod_is_enabled gssapi-with-mic debug1: Next authentication method: gssapi-with-mic debug1: Unspecified GSS failure. Minor code may provide more information No Kerberos credentials available (default cache: KEYRING:persistent:1211402155) debug1: Unspecified GSS failure. Minor code may provide more information No Kerberos credentials available (default cache: KEYRING:persistent:1211402155) debug2: we did not send a packet, disable method debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/myuser/.ssh/id_rsa debug3: send_pubkey_test debug3: send packet: type 50 debug2: we sent a publickey packet, wait for reply debug3: receive packet: type 51 debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password debug1: Trying private key: /home/myuser/.ssh/id_dsa debug3: no such identity: /home/myuser/.ssh/id_dsa: No such file or directory debug1: Trying private key: /home/myuser/.ssh/id_ecdsa debug3: no such identity: /home/myuser/.ssh/id_ecdsa: No such file or directory debug1: Trying private key: /home/myuser/.ssh/id_ed25519 debug3: no such identity: /home/myuser/.ssh/id_ed25519: No such file or directory debug2: we did not send a packet, disable method debug3: authmethod_lookup password debug3: remaining preferred: ,password debug3: authmethod_is_enabled password debug1: Next authentication method: password myuser@centos-b's password: Contrast this to what I see going from centos-b to centos-a, which works:
... debug1: Unspecified GSS failure. Minor code may provide more information Server not found in Kerberos database debug3: send packet: type 50 debug2: we sent a gssapi-with-mic packet, wait for reply debug3: receive packet: type 51 debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password debug2: we did not send a packet, disable method debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/myuser/.ssh/id_rsa debug3: send_pubkey_test debug3: send packet: type 50 debug2: we sent a publickey packet, wait for reply debug3: receive packet: type 60 debug1: Server accepts key: pkalg rsa-sha2-512 blen 279 debug2: input_userauth_pk_ok: fp SHA256:nAO5pVOzqUQzEUSEBN37WKp6ADs9Sk4rfTRGmk0FHEY debug3: sign_and_send_pubkey: RSA SHA256:nAO5pVOzqUQzEUSEBN37WKp6ADs9Sk4rfTRGmk0FHEY debug3: send packet: type 50 debug3: receive packet: type 52 debug1: Authentication succeeded (publickey). I've enabled sshd log messages in /etc/ssh/sshd_config and restarted the service
# Logging SyslogFacility AUTH SyslogFacility AUTHPRIV LogLevel INFO But there are no additional useful messages in either /var/log/secure or /var/log/messages.
Interestingly the ssh from centos-b to centos-b is using gssapi authentication. If I force it to use publickey it fails:
[myuser@centos-b ~]$ ssh -vvv -o PreferredAuthentications=publickey centos-b hostname ... debug1: Offering RSA public key: /home/myuser/.ssh/id_rsa debug3: send_pubkey_test debug3: send packet: type 50 debug2: we sent a publickey packet, wait for reply debug3: receive packet: type 51 ... Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). and I see in /var/log/messages:
Jul 7 13:52:10 centos-b sshd[23266]: Connection closed by 192.168.1.100 port 48064 [preauth] pubkey is enabled:
[root@centos-b ssh]# sshd -T | grep -i pub pubkeyauthentication yes pubkeyacceptedkeytypes [email protected],ecdsa-sha... The sshd_config is a stock Centos7 sshd_config, and is identical between centos-a and centos-b (verified by piping the following command through md5sum on both machines
[root@centos-b ssh]# grep -v -e '^#' -e '^$' /etc/ssh/sshd_config HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_ecdsa_key HostKey /etc/ssh/ssh_host_ed25519_key SyslogFacility AUTHPRIV AuthorizedKeysFile .ssh/authorized_keys PasswordAuthentication yes ChallengeResponseAuthentication no GSSAPIAuthentication yes GSSAPICleanupCredentials no UsePAM yes X11Forwarding yes 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 AcceptEnv XMODIFIERS Subsystem sftp /usr/libexec/openssh/sftp-server Any suggestions for what I'm missing?
debug3: receive packet: type 51is a genericSSH2_MSG_USERAUTH_FAILUREperssh2.h. What does thesshd_configlook like on the servers?sshd_configis the stock one installed with Centos7; I'll update the question with the contents