預設埠口 22。編輯 /etc/ssh/sshd_config:
#Port 22
Port 8888
重啟服務:service sshd restart
編輯 /etc/ssh/sshd_config:
#PermitRootLogin yes
PermitRootLogin no
重啟服務(建議 reboot)。
使用 PAM 模組實現白名單機制:
/etc/pam.d/sshd,在 #%PAM-1.0 後加入:
auth required pam_listfile.so item=user sense=allow file=/etc/ssh_users onerr=fail
abc)遠端登入:
echo abc >> /etc/ssh_users
/etc/ssh_users 移除該使用者,或刪除檔案 rm -rf /etc/ssh_users。透過修改預設埠口、停用 Root 遠端登入、實施使用者白名單,可大幅提升 SSH 服務安全性,有效防範暴力破解與未授權存取。