萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 作業系統 >  >> Solaris 介紹

Solaris 10/11 啟用 SSH 服務完整設定指南

Solaris 預設可能未啟用 SSH 服務,或配置不符合安全最佳實務。以下為完整啟用與強化步驟:

1. 確認/安裝 SSH 套件

  • Solaris 10: pkginfo | grep SUNWssh (含 SUNWsshcu, SUNWsshdr, SUNWsshdu, SUNWsshr, SUNWsshu)。缺失時從 Solaris DVD/ISO 安裝:pkgadd -d /path/to/DVD/Solaris_10/Product SUNWssh*。
  • Solaris 11: pkg install pkg://solaris/network/ssh (通常預裝)。

2. 啟用 SSH 服務

svcadm enable network/ssh
svcs -l network/ssh  # 確認狀態為 online

3. 強化 /etc/ssh/sshd_config 關鍵參數

Port 22
Protocol 2
PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
UsePAM yes
AllowUsers adminuser @wheelgroup
# 或 AllowGroups sshusers
MaxAuthTries 3
LoginGraceTime 30
ClientAliveInterval 300
ClientAliveCountMax 2
Banner /etc/issue
LogLevel VERBOSE
# 限制加密演算法 (現代建議)
Ciphers aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr
MACs hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com
KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256

4. 產生/部署主機金鑰

ssh-keygen -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key -N ""
ssh-keygen -t ecdsa -b 521 -f /etc/ssh/ssh_host_ecdsa_key -N ""
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ""

5. 使用者金鑰認證設定

  • 用戶端產生金鑰對:ssh-keygen -t ed25519 (推薦) 或 RSA 4096。
  • 公開金鑰加入伺服器 ~/.ssh/authorized_keys (權限 600,目錄 700)。
  • 可使用 ssh-copy-id user@solaris-host 自動部署。

6. 重啟服務驗證

svcadm restart network/ssh
ssh -v user@localhost  # 本機測試金鑰登入

7. 連動防火牆與入侵防禦

  • IPFilter 規則 (/etc/ipf/ipf.conf):pass in quick proto tcp from any to any port = 22 keep state。
  • 部署 pf (Solaris 11.4+) 或 fail2ban (需 Python 環境) 封鎖多次失敗 IP。

8. 稽核 SSH 登入事件

auditconfig -setpolicy +argv
auditconfig -setflags lo,ex,ss
# 登入/登出、執行、SSH 事件將記錄至 /var/audit/

驗證清單: Root 禁登、密碼禁用、金鑰強制、強加密套件、閒閒逾時斷線、暴力破解防護、完整稽核日誌。

copyright © 萬盛學電腦網 all rights reserved