3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Raspberry Pi: Raspbian ssh: kex_exchange_identification: read: Connection reset by peer

Last updated at Posted at 2022-02-17

現象

$ ssh pi@raspberrypi.local
kex_exchange_identification: read: Connection reset by peer
Connection reset by xxxx:38:e307:1:dadc:95b0:yyyy:zzzz port 22

$ ssh -v pi@raspberrypi.local
OpenSSH_8.6p1, LibreSSL 2.8.3
debug1: Reading configuration data /Users/USERNAME/.ssh/config
debug1: /Users/USERNAME/.ssh/config line 6: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to raspberrypi.local port 22.
debug1: Connection established.
debug1: identity file /Users/USERNAME/.ssh/id_rsa type 0
debug1: identity file /Users/USERNAME/.ssh/id_rsa-cert type -1
debug1: identity file /Users/USERNAME/.ssh/id_dsa type -1
debug1: identity file /Users/USERNAME/.ssh/id_dsa-cert type -1
debug1: identity file /Users/USERNAME/.ssh/id_ecdsa type -1
debug1: identity file /Users/USERNAME/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/USERNAME/.ssh/id_ecdsa_sk type -1
debug1: identity file /Users/USERNAME/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /Users/USERNAME/.ssh/id_ed25519 type -1
debug1: identity file /Users/USERNAME/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/USERNAME/.ssh/id_ed25519_sk type -1
debug1: identity file /Users/USERNAME/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /Users/USERNAME/.ssh/id_xmss type -1
debug1: identity file /Users/USERNAME/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.6
kex_exchange_identification: read: Connection reset by peer
Connection reset by xxxx:38:e307:1:dadc:95b0:yyyy:zzzz port 22

$ ls ~/.ssh/
authorized_keys	id_rsa		known_hosts
config		id_rsa.pub	known_hosts.old

$ cat ~/.ssh/config
host local
  hostname localhost
  user USERNAME
  IdentityFile ~/.ssh/id_rsa

Host *
   UseKeychain yes
   AddKeysToAgent yes
$ 

一度コネクションを確立してその後切断されているので、認証系のエラーのようだが原因不明。昨日まではsshできていた。

sshが『kex_exchange_identification: read: Connection reset by peer』のエラーとなりRaspberry Piに接続できなくなったときの解決法

こちらの動画「Raspberry Pi: Raspbian ssh: kex_exchange_identification: read: Connection reset by peer」で説明していた3つの解決法を載せておく。

Solution #1 / 3

I cleared a "kex_exchange_identification: read: Connection reset by peer" error i was getting trying to ssh into a pi by rebooting my client - turns out it was my workstaion with the issue not the pi. Hope this helps someone who found themselves on this thread for the same reason.

Google翻訳
「kex_exchange_identification:read:Connection reset by peer」エラーをクリアしました。クライアントを再起動して、piにSSH接続しようとしていました。これは、piではなく問題のあるワークステーションであることがわかりました。これが同じ理由でこのスレッドに自分自身を見つけた誰かを助けることを願っています。

Solution #2 / 3

I would look at the end of /var/log/auth.log on the reaspberrypi to see if there are any clues as to why sshd is disconnecting.

"Connection reset by peer" is often a symptom of IP address conflict -- multiple hosts trying to use the same IP address. Doesn't seem like that's the case here, but it's easy enough to check: run the arp command repeatedly and see if the MAC address for the raspberrypi is ever wrong.

Or just reboot the respberrypi? That'll restart sshd, which may clear any problems it might be experiencing. Plus it will force the raspberrypi to re-request its DHCP lease which is an opportunity to detect and fix any IP address conflict (assuming you're using DHCP, of cource).

Google翻訳
reaspberrypiの/var/log/auth.logの最後を見て、sshdが切断されている理由についての手がかりがあるかどうかを確認します。
「ピアによる接続のリセット」は、多くの場合、IPアドレスの競合の兆候です。複数のホストが同じIPアドレスを使用しようとしています。 ここではそうではないようですが、確認するのは簡単です。arpコマンドを繰り返し実行し、raspberrypiのMACアドレスが間違っていないかどうかを確認します。
または、respberrypiを再起動しますか? これによりsshdが再起動し、発生している可能性のある問題が解消される可能性があります。さらに、raspberrypiにDHCPリースを再要求するように強制します。これは、IPアドレスの競合を検出して修正する機会です(DHCPを使用していると仮定します)。

Solution #3 / 3

After facing lots of additional weird problems it turned out, that the micro sd card was just damaged. After trying a new one, everything seems to work as expected.

Google翻訳
さらに多くの奇妙な問題に直面した後、microsdカードが損傷したばかりであることが判明しました。 新しいものを試した後、すべてが期待どおりに機能しているようです。

今回、自分の場合は、Raspberry Pi Zeroを強制的に再起動(電源USBの抜き差し)したらsshがつながるようになった

原因は不明のままだ。

3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?