Lightsail: CLIENT_UNAUTHORIZED [769]

事象

Lightsailコンソールからのログインでエラー。DistroUbuntu 18.04LTSを20.04LTSにアップグレードしたもの。

CLIENT_UNAUTHORIZED [769]

原因

新しいバージョンのSSH (8.2) から、SHA-1ハッシュのサポートが標準ではサポートされなくなっているため。 旧バージョンからアップグレードした場合、公開鍵の署名がSHA-1のままになっている。

Future deprecation notice

It is now possible[1] to perform chosen-prefix attacks against the SHA-1 hash algorithm for less than USD$50K. For this reason, we will be disabling the "ssh-rsa" public key signature algorithm that depends on SHA-1 by default in a near-future release.

This algorithm is unfortunately still used widely despite the existence of better alternatives, being the only remaining public key signature algorithm specified by the original SSH RFCs.

調査

Ubuntuの場合、 sshd のログは、 /var/log/auth.log にある。 中身を見てみると、以下のログを発見。

Jan  1 02:38:22 ip-172-26-5-22 sshd[1066128]: userauth_pubkey: certificate signature algorithm ssh-rsa: signature algorithm not supported [preauth]
Jan  1 02:38:22 ip-172-26-5-22 sshd[1066128]: Connection closed by authenticating user ubuntu 54.240.XXX.XXX port 2190 [preauth]

対応

いったん、SSH-RSAを許可。でも、クラックされるからサポートされなくなったわけで、本来は公開鍵を変えるべき。

# diff sshd_config sshd_config_backup-2021-01-01
125,126d124
<
< CASignatureAlgorithms ^ssh-rsa

参考情報

以下のAWS Developer Forumにある事象と同じと思われる。

[https://forums.aws.amazon.com/thread.jspa?threadID=307027:What causes a "CLIENT_UNAUTHORIZED [769]" login error?]

これはHashicorpの例だけど、同じ原因みたい。

sarunas-krisciukaitis.medium.com