最終更新日:2020.08.26
こんにちわ!ナコです。
macのターミナルからSSH接続しようと思ったらSSH接続エラーがでたのでその対処法です。
入力したコマンド
$ ssh -L ○○○@▲▲▲.co.jp -p 22
ポート 22
サーバー ▲▲▲.co.jp
ユーザー名 ○○○
にSSH接続しにいっています。
エラー内容
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 RSA key sent by the remote host is
SHA256:6BpTXigPovfzdH8FKJEKDIOPchOXLZrXTnj0enG6qrE.
Please contact your system administrator.
Add correct host key in /Users/○〇〇/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/〇〇〇/.ssh/known_hosts:8
RSA host key for ▲▲▲.co.jp has changed and you have requested strict checking.
Host key verification failed.
@ 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 RSA key sent by the remote host is
SHA256:6BpTXigPovfzdH8FKJEKDIOPchOXLZrXTnj0enG6qrE.
Please contact your system administrator.
Add correct host key in /Users/○〇〇/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/〇〇〇/.ssh/known_hosts:8
RSA host key for ▲▲▲.co.jp has changed and you have requested strict checking.
Host key verification failed.
ワーニングこわい・・・!めちゃ怒られてる…
解決方法
$ ssh-keygen -R ▲▲▲.co.jp -p 22
ローカルで保存しているknown_hostsの設定をリセットしたら治ります!
実行すると…
# Host ▲▲▲.co.jp
/Users/〇〇〇/.ssh/known_hosts updated.
Original contents retained as /Users/〇〇〇/.ssh/known_hosts.old
/Users/〇〇〇/.ssh/known_hosts updated.
Original contents retained as /Users/〇〇〇/.ssh/known_hosts.old
バックアップもつくってくれるよ!
再接続
設定をリセットしたら再接続。
$ ssh -L ○○○@▲▲▲.co.jp -p 22
The authenticity of host ‘▲▲▲.co.jp (111.111.11.1)’ can’t be established.
ECDSA key fingerprint is SHA256:g38r+2aM2bPrkfJNjY#FKJEKDIOPchOX/gFnX+P4.
Are you sure you want to continue connecting (yes/no)? yes
The authenticity of host ‘▲▲▲.co.jp (111.111.11.1)’ can’t be established.
ECDSA key fingerprint is SHA256:g38r+2aM2bPrkfJNjY#FKJEKDIOPchOX/gFnX+P4.
Are you sure you want to continue connecting (yes/no)? yes
Are you sure you want to continue connecting (yes/no)? yes
と、新しくknown_hostsの設定をしますかと聞かれるのでyesとします。
無事に繋がりました〜!!