Linux 默認(rèn)端口號(hào)為22,使用起來(lái)非常不安全,所以需要修改端口號(hào)
修改端口
1. 編寫(xiě) sshd 配置文件
ssh_config 是客戶端
sshd_config 是服務(wù)端
vi /etc/ssh/sshd_config
在 #Port 22 下一行添加 Port xxx(你的端口號(hào))
2. 重啟 sshd
systemctl restart sshd
系統(tǒng)沒(méi)有任何提示表示成功
3. 防火墻開(kāi)放端口
firewall-cmd --zone=public --add-port=你的端口號(hào)/tcp --permanent
重啟 sshd 錯(cuò)誤
錯(cuò)誤信息
如果重啟 sshd 錯(cuò)誤,有可能出現(xiàn)以下錯(cuò)誤信息
“Job for sshd.service failed because the control process exited with error code.See ‘systemcl status& sshd service" and fournalcti xe'for details.”
可以通過(guò)?fournalcti xe 來(lái)查看詳細(xì)信息
解決方法
1.?首先安裝?semanage
yum install policycoreutils-python
?2. semanage 添加端口號(hào)
semanage port -m -t ssh_port_t -p tcp 你的端口號(hào)
注:如果報(bào)未定義,執(zhí)行下面命令
semanage port -a -t ssh_port_t -p tcp 你的端口號(hào)
3. 查看端口號(hào)是否已經(jīng)添加到列表里
semanage port -l |grep?ssh
4. 重啟 sshd文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-801898.html
systemctl restart sshd
?文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-801898.html
到了這里,關(guān)于Linux 修改 SSH 默認(rèn)22端口的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!