1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【AWS EC2】多段sshでssh_exchange_identificationエラーでログインできないとき

Last updated at Posted at 2020-08-29

AWS EC2で踏み台サーバーを介して多段SSHでログインしようとした際にssh_exchange_identification: Connection closed by remote hostと表示される

先日、普段使っているPCとは別のマシンで多段SSHをしようとしたところ、ssh_exchange_identification: Connection closed by remote hostというエラーが表示されて、ログインできないというトラブルが発生。
(多段SSHの設定は./ssh/configに書いてある)

# ホスト名をprod-serverとしているとする
# 踏み台サーバーを介してログインしようとする
$ ssh prod-server

# ログインできない
# => ssh_exchange_identification: Connection closed by remote host

踏み台サーバーのknown_hostsを消してみる

設定ファイルを確認してみたものの、ログイン対象インスタンスのパブリックIPは合っており、特に間違いもなかった。
そこで色々調べて、.ssh/以下のknown_hostsを削除してみたもののエラーが解決されない。

# ホスト名をbastion-serverとしているとする
$ ssh bastion-server

# 踏み台サーバーにはログインできる。`known_hosts`を削除
ubuntu@ip-xxx-xx-x-xxx:~$ rm ~/.ssh/known_hosts

多段SSHしているので、踏み台サーバーの./ssh/known_hostsも削除してみたらと思いついて、消してみたところ正常にログインできるようになった。

これを機にちゃんとSSHと関連知識を身につけたいなと思いました。

1
0
1

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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?