作者彙整: ishm

RockyLinux 8.x 符合資安驗證帳密規範設定SOP

為符合資安ISO27001驗證,須針對系統帳號進行安全設定。

資安規範:
密碼管理系統應為互動式: 強度太低會告知密碼強度不足
密碼長度至少8字元
複雜度要求: (大小寫、英數……)
最長天數: 90
最短天數: 1
驗證失敗機制:失敗5次上鎖15分鐘
密碼代數: 不能與前三代相同

閱讀全文

500 OOPS: vsftpd: refusing to run with writable root inside chroot()

vsftpd 在尚未出現帳號登入提示前,就出現 500 OOPS: vsftpd: refusing to run with writable root inside chroot() 的錯誤訊息,是因為 vsftpd 為了增強安全,當帳號可使用 chroot() 目錄時,該目錄就不得為可寫入(writeable)。

而在尚未出現使用者帳號登入提示前,就出現該錯誤,要去修改 secure_chroot_dir 的寫入權限,在 /etc/vsftpd.conf 裡面會指定 secure_chroot_dir 的位置:

secure_chroot_dir=/var/run/vsftpd/empty

將該目錄的寫入權限移除,該目錄只要移除 other 的 w 權限,然後重啟 vsftpd 服務即可:

#chmod o-w secure_chroot_dir=/var/run/vsftpd/empty
#service vsftpd restart

閱讀全文

systemctl status 訊息被截斷

使用 systemctl status 查詢服務狀態時,有時服務出現錯誤會有錯誤訊息,但常常會因螢幕寬度的問題,文字被截斷,可使用:

#systemctl status --no-pager --full

這樣訊息會全部顯示,不會被截斷了。

利用 firewall-cmd 建立封包轉送並記錄機制

使用 firewll-cmd 建立封包 forward 機制,可使用:
#firewall-cmd --permanent --add-forward
#firewall-cmd --permanent --add-masquerade
#firewall-cmd --permanent --add-forward-port=port=53:proto=udp:toport=53:toaddr=8.8.8.8
#firewall-cmd --reload

上面的指令,可以將DNS查詢的封包,全部轉送到Google DNS去。
閱讀全文

grep 使用正規表示式找 IPv4 及 IPv6 位址

IPv4:

grep -Eo "([0-9]{1,3}[.]){3}[0-9]{1,3}" filename

IPv6:

grep -Eo "([0-9a-fA-F]{4}[:])([0-9a-fA-F]{0,4}[:]){0,6}([0-9a-fA-F]{0,4})" filename

因為目前有效的IPv6格式,前置為 2001、ff80、ff02,所以使用 ([0-9a-fA-F]{4}[:]) 做為開頭 (排除 ::1 格式)。