LoginSignup
24
2

More than 1 year has passed since last update.

EC2で立てたサーバにsshする際にエラーが発生してしまう

Last updated at Posted at 2022-06-30

問題

EC2で立てた踏み台サーバからEC2サーバに対して、ipアドレスでsshする場合は問題なくできるが、ホスト名を指定する場合はエラーが発生してしまう

$ ssh -A ip-xx-xx-xx-xx.ap-northeast-1.compute.internal

ssh: Could not resolve hostname  ホスト名 : Name or service not known

原因

VPCのDNSホスト名の設定が『無効』になっていた

解決策

DNSホスト名を編集をクリック

スクリーンショット 2022-06-13 3.29.16.png

有効化をチェック

スクリーンショット_2022-06-13_3_11_06.png

DNSホスト名が有効になっていることを確認

スクリーンショット_2022-06-13_2_35_03.png

$ ssh -A ip-xx-xx-xx-xx.ap-northeast-1.compute.internal

       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/

まとめ

ホスト名なしのipのみでsshコマンドを実行した場合は接続に成功していたので解決に時間がかかってしまった

DNSホスト名の設定はデフォルトだと「有効」になっているはずなので、何かのタイミングで無効にしてしまっていたのかもしれない

参考にしたwebページ

24
2
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
24
2