Solaris 10 內建 OpenSSH (基於 OpenBSD 版本),支援 SSH 1.x/2.x 協定。商業版 SSH (SSH Communications Security) 為付費替代方案。預設服務 svc:/network/ssh:default 隨系統啟動。
# 確認服務狀態
svcs ssh
# STATE STIME FMRI
# online 10:30 svc:/network/ssh:default
建議停用不安全的 telnet:svcadm disable svc:/network/telnet:default。

/etc/ssh/sshd_config (服務端)格式:Keyword Value,關鍵字不分大小寫,# 為註解。關鍵安全參數建議值:
| 參數 | 建議值 | 說明 |
|---|---|---|
Protocol | 2 | 強制使用 SSH v2 協定,禁用不安全的 v1 |
Port | 22 | 監聽埠,建議改非標準埠 (如 2222) 減少掃描 |
ListenAddress | :: 或具體 IP | 綁定特定介面,預設全介面 |
PermitRootLogin | no | 禁止 root 直接登入,改用一般用戶 su/sudo |
PasswordAuthentication | yes (過渡期) / no (強制金鑰) | 密碼驗證,生產環境建議關閉改用金鑰 |
PermitEmptyPasswords | no | 拒絕空密碼登入 |
PubkeyAuthentication | yes | 啟用公開金鑰驗證 |
AuthorizedKeysFile | .ssh/authorized_keys | 公鑰檔案位置 |
StrictModes | yes | 檢查用戶家目錄/金鑰檔權限 (700/600) |
MaxAuthTries | 3 | 限制驗證嘗試次數 |
LoginGraceTime | 60 | 登入寬限秒數 |
X11Forwarding | yes | 允許 X11 轉發 (圖形應用需求) |
AllowTcpForwarding | no | 禁用 TCP 埠轉發 (減少隧道濫用) |
GatewayPorts | no | 禁用閘道埠轉發 |
SyslogFacility | AUTH | 日誌設施 |
LogLevel | INFO | 日誌等級,DEBUG 過於詳繁 |
HostKey | /etc/ssh/ssh_host_rsa_key/etc/ssh/ssh_host_dsa_key | 主機私鑰檔案 |
KeyRegenerationInterval | 3600 | 金鑰重生成間隔 (秒),v1 協定用 |
ServerKeyBits | 2048 | 伺服器金鑰長度 (v1),建議 2048+ |
Subsystem sftp | /usr/lib/ssh/sftp-server | SFTP 子系統 |
IgnoreRhosts | yes | 忽略 .rhosts 檔案 |
RhostsAuthentication | no | 禁用 rhosts 驗證 |
RSAAuthentication | yes | 允許 RSA 金鑰驗證 (v1) |
/etc/ssh/ssh_config全域用戶端預設值,可被 ~/.ssh/config 覆蓋。關鍵參數:
Host *
ForwardAgent no # 不轉發認證代理
ForwardX11 no # 不自動轉發 X11
RhostsAuthentication no
RhostsRSAAuthentication no
RSAAuthentication yes
PasswordAuthentication yes
FallBackToRsh no # SSH 失敗不回退 RSH
UseRsh no
BatchMode no # 腳本模式設 yes 禁用互動輸入
CheckHostIP yes # 檢查 IP 防 DNS 欺騙
StrictHostKeyChecking ask # 首次連線詢問是否信任新主機金鑰
IdentityFile ~/.ssh/identity
Port 22
Cipher aes256-ctr,aes192-ctr,aes128-ctr # 現代加密套件優先
EscapeChar ~
# 服務端生成主機金鑰 (安裝後通常已自動生成)
ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N ""
ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key -N ""
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ""
# 用戶端生成個人金鑰對
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -C "user@host"
# 複製公鑰到遠端
ssh-copy-id user@remote_host
# 或手動
cat ~/.ssh/id_ed25519.pub | ssh user@remote_host "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
# 遠端 sshd_config 確認
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no # 驗證金鑰登入正常後關閉密碼
# 重新載入服務
svcadm restart ssh
/etc/hosts.deny
sshd: ALL
/etc/hosts.allow
sshd: 192.168.1.0/255.255.255.0 10.0.0.0/255.0.0.0