Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

CentOS 設定 SSHD 開機自動啟動:chkconfig 與 systemctl 兩種方式

編輯:Linux 教學

確保遠端管理不中斷,SSH 服務必須開機自啟。

CentOS 6 (SysV init)

# 檢查現狀
chkconfig --list | grep sshd
# 輸出 sshd 0:off 1:off 2:off 3:off 4:off 5:off 6:off 表示未啟用

# 設定 runlevel 3/5 自啟
chkconfig --level 35 sshd on
# 或直接
chkconfig sshd on

CentOS 7/8 (systemd)

systemctl enable sshd
systemctl is-enabled sshd  # 應回傳 enabled

立即啟動服務

# CentOS 6
service sshd start
/etc/init.d/sshd start

# CentOS 7/8
systemctl start sshd

驗證

netstat -ntlp | grep :22
ss -ntlp | grep :22

設定完成後,伺服器重啟仍可透過 SSH 遠端登入管理。

Copyright © Windows教程網 All Rights Reserved