エラーの園

仕事、日常のあらゆるエラーと戦い、先人の知恵も拝借して何としても解決……したい!

ssh: connect to host [IPアドレス] port [ポート番号]: connection refused

エラー発生前の操作や設定など

ssh -p 10022 [user_id]@[LinuxマシーンのIPアドレス]
を実行した。

エラー内容

ssh: connect to host [IPアドレス] port 10022: connection refused  

参考サイト

1.stackoverflow#15118

ja.stackoverflow.com
ありがとうございます!助かりました🙇🏻‍♀️

2.ubuntu server での SSH の設定方法

yamamo10.jp
ありがとうございます!詳しい解説、助かります🙇🏻‍♀️
今後も、活用させていただきます😊

原因

どこかのサイトでglobal_IPアドレスを指定していたのを、そのまま鵜呑みにして実施していたため。
。。。必死になってglobal_IPアドレスに対してping叩いていた。
よくよく考えたら同じLan内のマシーンに接続するからglobal_IPアドレスは変だ💦
すぐに気がつかなかった自分が恥ずかしい😖

作業環境

$ sw_vers  
ProductName:    Mac OS X  
ProductVersion: 10.15.4  
OS:"Ubuntu"
VERSION:"14.04.6 LTS, Trusty Tahr"

解決手順

1.参考サイト1のunaristさんの回答に記載されていた確認項目を確認した。

※1−1〜4は参考サイトのunaristさんの回答を引用。

1−1.IPアドレスが間違っていて、別のPCを指している。

global_IPアドレスにこだわりすぎて、あれこれ確認したが、
一旦中断して別の用事をしている時に、不意に「なんでglobal_IPアドレス?」と気がつきIPアドレスで試した。

$ ssh -p 10022 [user_id]@[LinuxマシーンのIPアドレス]  
The authenticity of host '[LinuxマシーンのIPアドレス]:10022 ([192.168.0.5]:10022)' can't be established.  
ECDSA key fingerprint is SHA256:kC5VJXTWAIZC53kItuS0PrPi1fykF2mz2XSqdPVLhCA.  
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes  
Warning: Permanently added '[LinuxマシーンのIPアドレス]:10022' (ECDSA) to the list of known hosts.  
[user_id]@[LinuxマシーンのIPアドレス]'s password:  
Welcome to Ubuntu 14.04.6 LTS (GNU/Linux 3.13.0-170-generic i686)  
  
 * Documentation:  https://help.ubuntu.com/  
  
The programs included with the Ubuntu system are free software;  
the exact distribution terms for each program are described in the  
individual files in /usr/share/doc/*/copyright.  
  
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by  
applicable law.  
1−2.接続先で sshd が起動していない

1−1.で解決したので確認していないが、
今後のために、確認方法を下記に記載しておく。
※参考サイト2より引用

systemctl start ssh SSH のデーモンを起動します.
systemctl stop ssh SSH のデーモンを停止します.
systemctl restart ssh SSH デーモンを再起動します.デーモンが実行されていない場合,起動します.
systemctl reload ssh 設定ファイルを再読込みします.
systemctl status ssh ステータスを表示します.

1ー3.接続に使うポートが間違っている

確認したが、正しかった。

1−4.ファイアウォールによって通信が遮断されている

1−1.で解決したので未実施。