2
0

More than 1 year has passed since last update.

AWS EC2のRHEL9にTeraTerm4からログインする

Last updated at Posted at 2022-12-30

突然EC2にログインできなくなった??

普段通りEC2を起動してTeraterm(バージョン4.106)からログインしようとしたところ、ある日突然以下の画面になってアクセスできなくなった・・・

image.png

ググってみた結果・・・

ssh-rsaのアルゴリズムがteratermだとSHA-1で、どうやらRHEL9からはSHA-1でのアクセスがNGになっているみたいです。

参考記事:
セキュリティーが強化された最新版のRed Hat Enterprise Linux 9 - 日経クロステック
OpenSSHがSHA-1を使用したRSA署名を廃止 - Nulab
OpenSSH、今後はRSA/SHA1をデフォルトで無効に - Think IT

対応① EC2起動時のユーザーデータにコマンドを追加する。

以下の参考記事にズバリの記載がありました。

参考記事:
Red Hat Customer Portral 3.9. SHA-1 を再度有効に

それをもとに、ユーザーデータに以下を加えてみます。

EC2起動時のユーザーデータ
#!/bin/bash
sudo update-crypto-policies --set DEFAULT:SHA1

image.png

これを入れたら、無事にログインできました。
暗号化ポリシーがDEFAULT:SHA1になっていることも確認できました。

TeraTeam
Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last login: Fri Dec 30 11:03:25 2022 from 217.178.22.41
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$ sudo update-crypto-policies --show
DEFAULT:SHA1
[ec2-user@ip-xxx-xxx-xxx-xxx ~]$

対応② Powershellからアクセスする。

以下の通り、Powershellからはアクセスできました。
アクセス後に対応①と同じコマンドを打ってDEFAULT:SHA1に設定した後は、Teratermからもアクセスできるようになりました。(再起動を推奨されたが、再起動しなくてもTeratermからもいけた。)

Powershell
PS C:> ssh -i .\xxxkey.pem ec2-user@ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com
The authenticity of host 'ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com (xxx-xxx-xxx-xxx)' can't be established.
ED25519 key fingerprint is SHA256:2XZ3bR13xYOGSk59jCMSaEGi1VsCSENXOB9MH16PpCM.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com' (ED25519) to the list of known hosts.
Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
[ec2-user@ip-172-31-37-42 ~]$
[ec2-user@ip-172-31-37-42 ~]$ sudo update-crypto-policies --set DEFAULT:SHA1
Setting system policy to DEFAULT:SHA1
Note: System-wide crypto policies are applied on application start-up.
It is recommended to restart the system for the change of policies
to fully take place.
[ec2-user@ip-172-31-37-42 ~]$ sudo update-crypto-policies --show
DEFAULT:SHA1
[ec2-user@ip-172-31-37-42 ~]$

今後は・・・

おそらくTeratermもSHA-1廃止対応を実施中だと思うので、その動向を見守ろうと思います。
ちなみに、EC2でAmazon Linux2を選択した場合は普通にTeratermでアクセスできました。しばらくは、とりあえずサーバー建てたいときはそっちのほうが楽かも・・・

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0