SSH服務默認端口為22,修改默認端口為10022
1.vim /etc/ssh/sshd_config 將port端口修改為10022
2.重新啟動sshd守護進程
systemctl restart sshd.service 重新啟動服務,提示"Bind to port 10022 on 0.0.0.0 failed: Permission denied."
經查閱資料,發現selinux未關閉所致
查看selinux狀態 getenforce 處於enforcing狀態
關閉selinux setenforce 0 此命令為零時關閉,永久關閉,需要修改/etc/selinux/config配置文件
可以用sed命令修改,sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
再次重啟sshd服務
3.遠程連接主機
ssh 10.0.0.4 10022 依舊連接失敗
檢查firewall服務狀態,為開啟狀態。關閉防火牆服務 systemctl stop firewalld.service,永久關閉防火牆,systemctl disable firewalld.service
再次嘗試連接主機,連接成功
4.總結
影響ssh服務的有selinux和主機防火牆,selinux導致無法正常修改端口,主機防火牆導致網絡無法接通。因此在部署服務前,關閉selinux和防火牆