3
5

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.

sshでの接続に失敗する場合の対処

Last updated at Posted at 2021-11-20

sshでラズパに接続しようとすると、以下のようなエラーが出ることがある。
sshでは最初に接続した時にホストの公開鍵を保存しています。
で、次の接続の時にホスト鍵を比較して前回と同じホストに接続したかを
確認するような仕組みになっているらしい。

保存していた鍵と違っていた場合に以下のエラーが出て接続できなくなるらしい。

% ssh pi@192.168.10.25
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ED25519 key sent by the remote host is
SHA256:EKvX5V61nQcKfwyd/r+iSsBCzaWvrCxCxGg1vPBbc+s.
Please contact your system administrator.
Add correct host key in /Users/nomura/.ssh/known_hosts to get rid of this message.
Offending ED25519 key in /Users/nomura/.ssh/known_hosts:8
Host key for 192.168.10.25 has changed and you have requested strict checking.
Host key verification failed.

ssh-keygetコマンドを使って鍵を削除します。

% ssh-keygen -R 192.168.10.25
# Host 192.168.10.25 found: line 8
/Users/nomura/.ssh/known_hosts updated.
Original contents retained as /Users/nomura/.ssh/known_hosts.old

再度sshで接続すると初回と同じ手順で接続することができるようになります。

% ssh pi@192.168.10.25       
The authenticity of host '192.168.10.25 (192.168.10.25)' can't be established.
ED25519 key fingerprint is SHA256:EKvX5V61nQcKfwyd/r+iSsBCzaWvrCxCxGg1vPBbc+s.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.10.25' (ED25519) to the list of known hosts.
pi@192.168.10.25's password: 
Linux raspberrypi 5.10.63-v7l+ #1459 SMP Wed Oct 6 16:41:57 BST 2021 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Nov 19 19:39:51 2021

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?