確保遠端管理不中斷,SSH 服務必須開機自啟。
# 檢查現狀 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
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 遠端登入管理。