33
22

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 5 years have passed since last update.

SSH接続時にエラー

Posted at

#事象
raspiのOSを焼き直したのちに、再度SSHで接続しようとしたところ、以下メッセージがでた。

$ ssh pi@192.168.1.10
Password:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 ECDSA key sent by the remote host is
SHA256:/DtVwEQbWOlTXlJx0f5UeZK0BiJtBZcvQmkFMphRUjE.
Please contact your system administrator.
Add correct host key in /var/root/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /var/root/.ssh/known_hosts:1
ECDSA host key for 192.168.1.10 has changed and you have requested strict checking.
Host key verification failed.

#対策方法
どうやら、以前のSSH接続時の認証キーが残っていることが原因のようです。

##過去の遺物を削除

$ vi /Users/[@ユーザー名]/.ssh/known_hosts 

#known_hostsの中身(一部)
192.168.1.10 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNzbWlQ3Y+TfQkWjIyDwWZBCLHZJwuFsIklWLKFUPdumIuGTK9FbrQ1SOEHHO/KoLx9Ta1VgbFoBM8XheSScLk4=

上記known_hostsの部分を削除。

Viの操作方法

操作 コマンド
削除 x
保存 :w
保存せずに閉じる :q!
保存して閉じる :wq

詳しくは viコマンド集

##再接続

$ ssh pi@192.168.1.10
The authenticity of host '192.168.1.10 (192.168.1.10)' can't be established.
ECDSA key fingerprint is SHA256:/DtVwEQbWOlTXlJx0f5UeZK0BiJtBZcvQmkFMphRUjE.
Are you sure you want to continue connecting (yes/no)? yes
                                                        ↑で「yes」と入力

Warning: Permanently added '192.168.1.10' (ECDSA) to the list of known hosts.
pi@192.168.1.10's password: 
Linux raspberrypi 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017 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 Dec 29 12:40:23 2017 from 192.168.1.4
pi@raspberrypi:~ $ 

無事ログインできました!

#参考
SSHサーバーが変わったら - profaim.jp

33
22
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
33
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?