[Linux] userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms
구버전 SSH 클라이언트로 최신 OS에 접속할 때 발생하는 key type ssh-rsa not in PubkeyAcceptedAlgorithms 오류를 시스템 암호화 정책 변경으로 해결하는 방법을 정리합니다.
요약
update-crypto-policies --set LEGACY로 시스템 암호화 정책을 이전 릴리즈 호환 정책으로 바꾸면 ssh-rsa 키 접속 오류를 우회할 수 있습니다.- 이 오류는 주로 Ubuntu 14.04 같은 구버전 OS나 SSH 클라이언트에서 Amazon Linux 2023 같은 최신 OS로 접속할 때
/var/log/secure에 기록됩니다. - LEGACY 정책을 적용하면 aes256-cbc, 3des-cbc 같은 cipher와 sha1 계열 kex 알고리즘이 허용 목록에 추가됩니다.
userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms 오류 해결 방법
주로 구버전의 운영체제 혹은 구버전의 SSH client 에서 최신 버전의 운영체제로 접속 할 때, 위와 같은 에러를 /var/log/secure 에서 확인 할 수 있습니다.
(예 /> Ubuntu 14.04 에서 Amazon Linux 2023 접속 할 때 등)
/var/log/secure 로그 내용은 아래와 같습니다.
(운영체제 마다 로그 위치는 차이가 있습니다.)
Jul 26 05:20:18 ip-172-31-35-0 sshd[7154]: userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]
Jul 26 05:20:18 ip-172-31-35-0 sshd[7154]: Connection closed by authenticating user ec2-user 172.31.41.36 port 53627 [preauth]
Jul 26 05:20:19 ip-172-31-35-0 sshd[7156]: userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]
Jul 26 05:20:19 ip-172-31-35-0 sshd[7156]: Connection closed by authenticating user ec2-user 172.31.41.36 port 53628 [preauth]
Jul 26 05:20:19 ip-172-31-35-0 sshd[7158]: userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms [preauth]
Jul 26 05:20:19 ip-172-31-35-0 sshd[7158]: Connection closed by authenticating user ec2-user 172.31.41.36 port 53629 [preauth]
Workaround
아래 명령어를 통해 시스템 암호화 정책을 이전 릴리즈와 호환 되는 정책으로 변경합니다.
$ sudo update-crypto-policies --set LEGACY
$ sudo update-crypto-policies --show
LEGACY
아래와 같이 기존에 시스템 암호화 정책이 이전 릴리즈와 호환 되도록 변경이 됩니다.
$ diff origin change
1c1
< ciphers aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes128-gcm@openssh.com,aes128-ctr
---
> ciphers aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc,3des-cbc
3c3
< kexalgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512
---
> kexalgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1
참고 자료
자주 묻는 질문
sshd 로그에 userauth_pubkey: key type ssh-rsa not in PubkeyAcceptedAlgorithms가 나오는 이유는 무엇인가요?
주로 구버전 운영체제나 구버전 SSH client에서 최신 버전의 운영체제로 접속할 때 발생합니다. 예를 들어 Ubuntu 14.04에서 Amazon Linux 2023으로 접속할 때 /var/log/secure에서 확인할 수 있습니다.
ssh-rsa 키 접속 오류를 서버 측에서 우회하려면 어떻게 하나요?
sudo update-crypto-policies --set LEGACY로 시스템 암호화 정책을 이전 릴리즈와 호환되는 정책으로 변경합니다. 적용 여부는 sudo update-crypto-policies --show의 출력이 LEGACY인지로 확인합니다.
LEGACY 암호화 정책으로 바꾸면 무엇이 달라지나요?
ciphers에 aes256-cbc, aes128-cbc, 3des-cbc가, kexalgorithms에 diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1이 추가됩니다.