sshd
是linux
下用來遠程的服務 ,默認為22端口。 一般用Xshell
,CRT
這些遠程工具遠程連接操作。
#這個就是sshd的配置文件。
vim /etc/ssh/sshd_config
修改為我們需要設置的端口
檢查配置是否無誤
sshd -t
這時 我發現執行ssh -t
沒有任何錯誤信息提示,但是重啟sshd
時總會失敗,使用systemctl status sshd.service
查看會提示如下錯誤
最后參考sshd修改端口后幾次啟動失敗重啟成功
具體關閉selinux
操作如下
## 查看SELinux狀態:
/usr/sbin/sestatus -v ##如果SELinux status參數為enabled即為開啟狀態
SELinux status: enabled
2、getenforce ##也可以用這個命令檢查
關閉SELinux:
## 1、臨時關閉(不用重啟機器):
setenforce 0 ##設置SELinux 成為permissive模式
##setenforce 1 設置SELinux 成為enforcing模式
## 2、修改配置文件需要重啟機器:
修改/etc/selinux/config 文件
將SELINUX=enforcing改為SELINUX=disabled
重啟機器即可
這時再執行啟動sshd
命令
systemctl restart sshd.service