中小型異構網路常選 Linux 提供 Internet 服務,FTP 為常見服務之一。但傳統 FTP 以明文傳輸帳號密碼與資料,易遭竊聽、中間人攻擊、暴力破解或 sniffer 截取封包盜取 root 密碼。
SSH (Secure Shell) 提供加密傳輸、防中間人、防 DNS/IP 欺騙、資料壓縮加速,可替代 Telnet、為 FTP/POP/PPP 提供安全通道。SSH 兩種驗證等級:基於口令 (ssh1) 僅需帳號密碼,傳輸加密但無法確認伺服器真偽,仍怕中間人;基於金鑰 (ssh2) 需建立金鑰對,公開金鑰放伺服器,挑戰-回應機制無需傳送密碼,更安全。但 OpenSSH 仍有口令/金鑰破解與木馬植入風險。
SRP (Secure Remote Password) 為開放原始碼認證協定。客戶端/伺服器不在網路上以明文或加密形式傳送密碼,徹底消除密碼欺騙,核心思想防禦被動/主動網路入侵者的字典攻擊。Stanford 大學開發 SRP 套件,提供基於口令認證與會話加密,無需用戶或管理員管理分發金鑰。優勢:
環境:Red Hat Linux 9.0。
SRP 官網:https://srp.stanford.edu,最新版 2.1.1。安裝前需先裝 OpenSSL。
# wget https://srp.stanford.edu/source/srp-2.1.1.tar.gz # cp /usr/src/redhat/SOURCES # ./configure --with-openssl=/usr/src/redhat/SOURCES/openssl-0.9.6 --with-pam # make && make install
EPS (Exponential Password System) 原始碼已含於 SRP 套件。
PAM (Pluggable Authentication Module) 將認證從應用程式獨立,處理認證、帳號、會話、密碼四類管理。工作流程:應用程式調用 → PAM 庫 → 讀 /etc/pam.d/ 配置 → 載入認證模組 → 與會話函式通訊 → 向用戶要求資訊 → 用戶回應 → PAM 庫回傳認證結果 → 應用程式授權或拒絕。
安裝 PAM 模組:
# cd /usr/src/redhat/SOURCES/srp-2.1.1/base/pam_eps # install -m 644 pam_eps_auth.so pam_eps_passwd.so /lib/security
再用 /usr/local/bin/tconf 建立 /etc/tpasswd 和 /etc/tpasswd.conf。
(1)備份 /etc/pam.d/system-auth。
(2)修改如下:
auth required /lib/security/pam_unix.so likeauth nullok md5 shadow auth sufficient /lib/security/pam_eps_auth.so auth required /lib/security/pam_deny.so account sufficient /lib/security/pam_unix.so account required /lib/security/pam_deny.so password required /lib/security/pam_cracklib.so retry=3 password required /lib/security/pam_eps_passwd.so password sufficient /lib/security/pam_unix.so nullok use_authtok md5 shadow password required /lib/security/pam_deny.so session required /lib/security/pam_limits.so session required /lib/security/pam_eps_passwd.so
完成配置,系統即可用 SRP 協定提供安全遠端認證服務,有效防範口令監聽與字典攻擊。