サーバにSSH接続できない
最終更新日 2022年10月7日
Webページには問題なくアクセスできる(ネットワーク接続に問題はない)が、以前はSSHで接続できていたLinuxサーバに接続できない場合、以下の画像のような警告が端末ソフトに表示されていないでしょうか。
現サーバのホスト鍵と端末が保持しているホスト鍵(旧サーバのもの)が異なっているために、警告が表示されて接続に失敗しています。
端末がMacの場合、ホスト鍵が保存されているファイルは /Users/ユーザ名/.ssh/known_hosts です。このファイルをテキストエディタで開いて、接続できないLinuxサーバの行を削除して保存した後、再度LinuxサーバにSSH接続してみてください。
Unable to Connect to Server via SSH
Last Updated: October 7, 2022
You can access the web page without any issues (indicating that your network connection is working), but if you are unable to connect to the Linux server via SSH—despite having been able to do so previously—you may be seeing a warning like the one shown in the image below on your terminal software.
This warning appears because the host key of the current server differs from the host key stored on your terminal (which belongs to the previous server). As a result, the connection fails. If you are using a Mac, the host key is stored in the file located at /Users/your-username/.ssh/known_hosts. Open this file with a text editor, delete the line corresponding to the Linux server you are trying to connect to, save the file, and then try connecting to the server again via SSH.