SSH公開鍵認証の秘密鍵ペアを作り直す
WSL2 のディストリビューションを Ubuntu 22.04.1 LTS にアップグレードしたタイミングで、リモートサーバーへの SSH 接続に失敗するようになってしまった。原因としては、このアップグレードにより OpenSSH のバージョンも更新されていたことに起因する。OpenSSH は 8.8 以降デフォルトで ssh-rsa をサポートしておらず、また秘密鍵ペアは RSA で生成していたため条件に合致していた。
OpenSSH will disable the ssh-rsa signature scheme by default in the
next release.
https://www.openssh.com/txt/release-8.7
クライアント側の OpenSSH バージョン確認
code:OpenSSH version
$ ssh -V
[OpenSSH_8.9p1 Ubuntu-3ubuntu0.1, OpenSSL 3.0.2 15 Mar 2022
既存の鍵でSSH認証するための回避策
code:~/.ssh/config
Host *
HostKeyAlgorithms ssh-rsa
PubkeyAcceptedKeyTypes ssh-rsa
新しい秘密鍵ペアを生成する
code:ssh-key-gen example
$ ssh-keygen -t ed25519 -P "" -f ~/.ssh/my-machine.pem -C "you@example.com"
参考URL
https://stackoverflow.com/questions/71108287/rsa-key-is-not-allowed
https://qiita.com/tukiyo3/items/b497c3ce285215a9cb02
https://qiita.com/wnoguchi/items/a72a042bb8159c35d056
https://medium.com/risan/upgrade-your-ssh-key-to-ed25519-c6e8d60d3c54
https://dev.classmethod.jp/articles/openssh78_potentially_incompatible_changes/#section-03
https://freak-da.hatenablog.com/entry/20100901/p1
#Linux