
前提・実現したいこと
ConoHaVPSを借りてSSHのセキュリティ設定をしています。
デフォルトのポート22を10222に変更しようと思って下記のサイトを参考に進めております。
その①
https://qiita.com/ongaeshi/items/bb17ebfbd4d22057c8fd
その②
https://qiita.com/EisKern/items/3a12bd61ba572e8430d9
/etc/ssh/sshd_configのポート番号変更を反映する際下記のエラーが表示されます。
下記で同様の質問がありましたが、解決した方法の反映が同様のエラーで変更できません。
何か解決策がありましたら、ご教授願います。
▼同様の質問
https://teratail.com/questions/122178
発生している問題・エラーメッセージ
/etc/ssh/sshd_configのPortを10222に変更し再起動しようとするとエラーが表示されます。
$ systemctl start sshd.service Job for sshd.service failed because the control process exited with error code. See "systemctl status sshd.service" and "journalctl -xe" for details.
▼systemctl status sshd.service
● sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Mon 2019-02-25 23:37:00 JST; 4s ago Docs: man:sshd(8) man:sshd_config(5) Process: 25613 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=255) Main PID: 25613 (code=exited, status=255) Feb 25 23:37:00 xxx-xx-xx-xx systemd[1]: sshd.service: main process exited, ...a Feb 25 23:37:00 118-27-35-77 systemd[1]: Failed to start OpenSSH server daemon. Feb 25 23:37:00 118-27-35-77 systemd[1]: Unit sshd.service entered failed state. Feb 25 23:37:00 118-27-35-77 systemd[1]: sshd.service failed. Hint: Some lines were ellipsized, use -l to show in full.
▼journalctl -xe
Feb 25 23:40:31 118-27-35-77 systemd[1]: Unit sshd.service entered failed state. Feb 25 23:40:31 118-27-35-77 systemd[1]: sshd.service failed.
該当のソースコード
▼/etc/ssh/sshd_configのPortを10222に変更
# If you want to change the port on a SELinux system, you have to tell # SELinux about this change. # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER # Port 10222 #~~省略~~
▼下記のコマンドを入力すると以下ののエラーが表示されます。
$ systemctl start sshd.service Job for sshd.service failed because the control process exited with error code. See "systemctl status sshd.service" and "journalctl -xe" for details.
試したこと
▼/etc/sysconfig/iptablesにてPortを22から10222に変更
※sudo service iptables restartで問題なく再起動出来ます。
# sample configuration for iptables service # you can edit this manually or use system-config-firewall # please do not ask us to add additional ports/services to this default configurr ation *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 10222 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
▼ローカルの~/.ssh/ssh_configもPort番号を変更しました。
#ConoHa Host conoha HostName xxx.xx.xx.xx Port 10222 User rutoki IdentityFile ~/.ssh/conoha
▼iptables,firewalldの自動起動は以下のとおりです。
systemctl list-unit-files | grep -e firewalld -e iptables firewalld.service disabled iptables.service enabled
補足情報(FW/ツールのバージョンなど)
ローカルOS: Mac OS 10.13.6
リモートOS: CentOS 7.6
VPSサーバ: ConoHa
回答1件
あなたの回答
tips
プレビュー