userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedKeyTypes [preauth]

Latest response

I am trying to setup SSH key for rhel8 and I seem to be unable to get it working. I have done the same steps on rhel 7.8 setup and it works fine. Any help would be appreciated.

I keep getting the following error and then it prompts me for my password.

Jul 27 20:09:34 host-192-168-10-50 sshd[2407]: userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedKeyTypes [preauth]

Here is my sshd config.

[root@host-192-168-10-50 ssh]# sshd -T
port 22
addressfamily any
listenaddress [::]:22
usepam yes
logingracetime 120
x11displayoffset 10
x11maxdisplays 1000
maxauthtries 6
maxsessions 10
clientaliveinterval 300
clientalivecountmax 0
streamlocalbindmask 0177
permitrootlogin no
ignorerhosts yes
ignoreuserknownhosts no
hostbasedauthentication no
hostbasedusesnamefrompacketonly no
pubkeyauthentication yes
kerberosauthentication no
kerberosorlocalpasswd yes
kerberosticketcleanup yes
kerberosuniqueccache no
kerberosusekuserok yes
gssapienablek5users no
gssapiauthentication yes
gssapicleanupcredentials no
gssapikeyexchange no
gssapistrictacceptorcheck yes
gssapistorecredentialsonrekey no
gssapikexalgorithms gss-gex-sha1-,gss-group14-sha1-
passwordauthentication yes
kbdinteractiveauthentication no
challengeresponseauthentication no
printmotd yes
printlastlog yes
x11forwarding yes
x11uselocalhost yes
permittty yes
permituserrc yes
strictmodes yes
tcpkeepalive yes
permitemptypasswords no
compression yes
gatewayports no
usedns no
allowtcpforwarding yes
allowagentforwarding yes
disableforwarding no
allowstreamlocalforwarding yes
streamlocalbindunlink no
fingerprinthash SHA256
exposeauthinfo no
pidfile /var/run/
xauthlocation /usr/bin/xauth
ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc
macs hmac-sha2-512,hmac-sha2-256,hmac-sha1,,,
banner /etc/issue
forcecommand none
chrootdirectory none
trustedusercakeys none
revokedkeys none
authorizedprincipalsfile none
versionaddendum none
authorizedkeyscommand none
authorizedkeyscommanduser none
authorizedprincipalscommand none
authorizedprincipalscommanduser none
hostkeyagent none
kexalgorithms curve25519-sha256,,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1
casignaturealgorithms ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
pubkeyacceptedkeytypes ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512
rdomain none
loglevel INFO
syslogfacility AUTHPRIV
authorizedkeysfile .ssh/authorized_keys
hostkey /etc/ssh/ssh_host_rsa_key
hostkey /etc/ssh/ssh_host_ecdsa_key
hostkey /etc/ssh/ssh_host_ed25519_key
acceptenv LANG
acceptenv LC_CTYPE
acceptenv LC_NUMERIC
acceptenv LC_TIME
acceptenv LC_COLLATE
acceptenv LC_MONETARY
acceptenv LC_MESSAGES
acceptenv LC_PAPER
acceptenv LC_NAME
acceptenv LC_ADDRESS
acceptenv LC_TELEPHONE
acceptenv LC_ALL
acceptenv LANGUAGE
acceptenv XMODIFIERS
authenticationmethods any
subsystem sftp /usr/libexec/openssh/sftp-server
maxstartups 10:30:100
permittunnel no
ipqos af21 cs1
rekeylimit 0 0
permitopen any
permitlisten any
permituserenvironment no


Hi Dan,

By default, the only entry that I could see in /etc/ssh/sshd_config file in RHEL8.1 is:

[root@rhel8 ~]# egrep -i 'pubkey*' /etc/ssh/sshd_config
#PubkeyAuthentication yes

The "pubkeyacceptedkeytypes" parameter list outs the following values:

[root@rhel8 ~]# sshd -T|egrep "pubkeyauthentication|pubkeyacceptedkeytypes"
pubkeyauthentication yes

So, it should work. I hope this may be the issue over there

Thanks for the link Sadashiva. I will try creating a new key and see if that resolves the issue. I did turn off FIPS hoping that would resolve it, but that didn't work.

[root@host-192-168-10-50 ~]# update-crypto-policies --show LEGACY

Ok, lets see if that works out.

I created a new key using ecdsa and that worked, but I still don't understand why ssh-rsa is not working.

Was the system rebooted after turning off FIPS? That is what is suggested. May be that you might have forgotten to do a reboot, hope not.

As per the document system needs a restart after FIPS mode is either enabled/disabled using the command "fips-mode-setup" ( --disable).

Yes, I did a reboot and verified that fips-mode-setup was disabled.