Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Solaris 系統配置獨立認證日誌與 Syslog 服務重啟實戰

編輯:Linux 教學

需求場景

在 Solaris 系統上,預設所有認證相關日誌(SSH 登入、su 切換、sudo 執行等)混雜於 /var/adm/messages,不利於安全稽核與異常追蹤。本文示範如何將 auth.info 級別日誌導向獨立檔案 /var/log/secure,並完成服務重啟驗證。

配置步驟

1. 修改 syslog 設定檔

編輯 /etc/syslog.conf(注意:Solaris 傳統為 syslog.conf,非 rsyslog.conf),新增以下規則:

auth.info    /var/log/secure

格式說明: 選擇器 auth.info 表示 auth 設施、info 以上級別;動作欄位為絕對路徑,Tab 鍵分隔。

2. 建立日誌檔案並設定權限

touch /var/log/secure
chmod 640 /var/log/secure
chown root:sys /var/log/secure

3. 重啟系統日誌服務

Solaris 10/11 使用 SMF 管理服務,執行:

svcadm restart system-log

舊版 Solaris 亦可嘗試:/etc/init.d/syslog restart

驗證成效

執行 SSH 登入測試後,查看新日誌:

cat /var/log/secure

輸出範例:

May 25 13:58:33 zhao-file sshd[893]: [ID 800047 auth.info] Accepted password for ckl from 180.168.81.54 port 53705 ssh2
May 25 13:59:45 zhao-file sshd[909]: [ID 800047 auth.info] Accepted publickey for ckl from 180.168.81.54 port 53706 ssh2
May 25 14:01:18 zhao-file sshd[938]: [ID 800047 auth.info] Did not receive identification string from 61.151.248.196
May 25 14:03:28 zhao-file sshd[911]: [ID 800047 auth.info] Received disconnect from 180.168.81.54: 0:
May 25 14:03:32 zhao-file sshd[895]: [ID 800047 auth.info] Received disconnect from 180.168.81.54: 0:

進階配置建議

  • 日誌輪轉: 配置 /etc/logadm.conf 定期切割 /var/log/secure,避免佔滿磁碟
  • 遠端傳送: 修改動作欄位為 @logserver.example.com 實現集中日誌收集
  • 細分級別: 若需分離失敗登入,可加入 auth.err /var/log/auth_fail.log

常見問題排查

  1. 日誌不生成: 確認 syslogd 進程存活 pgrep syslogd,檢查磁碟空間 df -h /var
  2. 權限拒絕: 確保 syslogd 對目標檔案有寫入權限,SELinux 環境需檢查上下文
  3. 格式錯誤: syslog.conf 要求 Tab 分隔,空格會導致解析失敗
Copyright © Windows教程網 All Rights Reserved