目標
参考URL
1.手順について
qiita.com
↑
ありがとうございます!助かりました🙇🏻♀️
2.SSH接続できない時に確認する項目
ja.stackoverflow.com
↑
ありがとうございます!おかげさまで解決しました🙇🏻♀️
参考書籍
Port番号を変更する理由について
ゼロからはじめるLinuxサーバー構築・運用ガイド 動かしながら学ぶWebサーバーの作り方 [ 中島能和 ] 価格:2,948円 |
↑
CentOSでの解説だが、Linuxの基本的な情報や注意点が分かりやすく
説明されている。
今後も、こちらの書籍を参考にLinuxサーバー構築の練習をしようと思う。
作業環境
$ sw_vers ProductName: Mac OS X ProductVersion: 10.15.4
OS:"Ubuntu" VERSION:"14.04.6 LTS, Trusty Tahr"
実施作業
1.openssh-server
をインストールする。
$ sudo apt-get install openssh-server
2.sshd_config
の編集
$ sudo vi /etc/ssh/sshd_config
# Package generated configuration file # See the sshd_config(5) manpage for details # What ports, IPs and protocols we listen for # Port 22 Port 10022 ...(中略)... #PermitRootLogin yes PermitRootLogin no ...(以下、省略)...
上記の設定について
▼Port
デフォルトのPort 22
は攻撃を受けやすいので変更する。
変更するPort番号は何でもいいが、1024以降で未割付のポート番号を設定する。
▼PermitRootLogin
rootユーザーでログインすることを
yes
:許可する。
no
:禁止する。
※参考書籍の解説を参考に記載しています。
3.サーバーの再起動
$ sudo /etc/init.d/ssh restart ssh stop/waiting ssh start/running, process 3279
4.Macから接続する。
$ 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.
【補足】
ssh: connect to host [IPアドレス] port 10022: connection refused
上記エラーがでたら、下記項目を確認する。
(参考URL2より引用)
・IPアドレスが間違っていて、別のPCを指している
・接続先で sshd が起動していない
・接続に使うポートが間違っている
・ファイアウォールによって通信が遮断されている