Friday, February 10, 2023

Windows时间同步注意点

Windows时间服务是Active Directory域正常运行的基础功能。AD主身份验证协议Kerberos使用W32Time(Windows时间)时间服务来正常运行。在AD环境中,时间同步是按照严格的层次结构进行的:加入域的电脑和服务器从距离最近的域控制器获取时间,所有域控制器与拥有FSMO角色的PDC Emulator的单个DC同步

PDC模拟器(Primary Domain Controller)与外部时间源同步时间。外部时间源通常是一个或多个公共NTP服务器

所有版本的Windows都有W32Time服务,这个服务用于和AD同步时间。一台电脑可以同时作为NTP服务端和客户端,默认情况下,加域的客户端电脑使用Windows时间服务来同步时间而不是使用NTP

Windows时间服务的默认情况如下:

  1. 完成Windows原版系统安装后,NTP客户端在电脑已启动,并用于和外部时间源同步时间
  2. 当电脑加域后,同步类型会改变,域中所有客户端电脑和成员服务器会自动和DC同步时间
  3. 当成员服务器提升为DC后,NTP服务端会启动,该服务器使用具有PDC角色的DC作为时间源
  4. PDC emulator 是整个组织的主要时间服务器,它会和外部时间源同步(或者和CMOS的硬件时间同步)
  5. 这个方案在大多数情况下都有效,不需要干预。但是,Windows中时间服务的结构可能不遵循域层次结构

 

使用GPO配置PDC DC的NTP:(注意此域策略只作用于域控制器)

Computer Configuration > Administrative Templates > System > Windows Time Service > Time Providers

  • Configure Windows NTP Client: Enabled (NtpServer: ntp.aliyun.com,0x1 Type: NTP)
  • Enable Windows NTP Client: Enabled
  • Enable Windows NTP Server: Enabled

 

使用GPO配置客户端时间同步:

Computer Configuration > Administrative Templates > System > Windows Time Service > Time Providers

  • Enable Windows NTP Client: Enabled (NtpServer: dc.xxx.com,0x9 Type: NT5DS)

 

NTP和NT5DS的区别:

  • NTP——与外部时间服务器同步
  • NT5DS——根据域层次结构执行同步,在加域的电脑上默认使用

 

参考:

https://theitbros.com/configure-ntp-time-sync-group-policy/

http://www.sysadminlab.net/windows/configuring-ntp-on-windows-using-gpo 

https://docs.microsoft.com/zh-cn/archive/blogs/nepapfe/its-simple-time-configuration-in-active-directory

Wednesday, December 7, 2022

C2960-48TT-L 升级固件

从 IOS12 升级到 IOS15

 

 1. 下载IOS软件,链接https://software.cisco.com/download/home/279963518/type/280805680/release/15.0.2-SE11(须先登录 Cisco 账户)


2. 通过 TFTP 传输 .bin 文件到交换机 flash

copy tftp://192.168.1.10/c2960-lanbasek9-mz.150-2.SE11.bin flash:/c2960-lanbasek9-mz.150-2.SE11.bin
3.
启用中断以免用到
(config)#boot enable-break
更改启动镜像文件
(config)#boot system flash:/c2960-lanbasek9-mz.150-2.SE11.bin
保存
(config)#do write
重启
(config)#do reload

 

参考:

https://www.nazaudy.com/how-to-upgrade-the-ios-version-in-cisco-switch-c2960s

Thursday, April 1, 2021

Web Application Potentially Vulnerable to Clickjacking (nginx)

在 nginx 配置文件添加:

add_header X-Frame-Options SAMEORIGIN;


三个选项:
DENY
表示该页面不允许在 frame 中展示,即便是在相同域名的页面中嵌套也不允许。
SAMEORIGIN
表示该页面可以在相同域名页面的 frame 中展示。
ALLOW-FROM URI
表示该页面可以在指定来源的 frame 中展示。
 

注: 在网页中设置meta标签是无用的!例如,<meta http-equiv="X-Frame-Options" content="deny"> 是没有效果的。不要使用这种方式。需要在下面的配置实例中配置HTTP Header的方式来进行配置,X-Frame-Options才会起作用。

 

参考:

https://www.imperva.com/learn/application-security/clickjacking/ 

https://www.jianshu.com/p/51cc683402f0

 

nginx SSL 安全密码套件

ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK

nginx.service: PID file /var/run/nginx.pid not readable (yet?) after start: No such file or dir

需要 Systemd 等待 nginx 创建 PID 文件之后再往下执行

 

1. 在服务配置文件 /usr/lib/systemd/system/nginx.service 添加一行:

ExecStartPost=/bin/sleep 0.1

 

2. 然后执行:systemctl daemon-reload

 

参考:

https://www.programmersought.com/article/95721475597/




 

Monday, March 8, 2021

CentOS 7 SSH 登录安全性加固

vi /etc/ssh/sshd_config

# 禁止 Root 账号登录

PermitRootLogin no

# 版本

Protocol 2

systemctl restart sshd

 

vi /etc/pam.d/sshd

# 在 auth 部分添加一行

# even_deny_root 表示同样限制 root 账号

# file 用于指定统计次数用的文件,默认是 /var/log/tallylog

auth required pam_tally2.so even_deny_root deny=5 unlock_time=300 file=/var/log/tallylog

# 如果不生效,则在 account 部分再添加一行

account required pam_tally2.so



vi /etc/profile.d/auto-logout.sh

# 添加一行

readonly TMOUT=300



参考:

https://man7.org/linux/man-pages/man8/pam_tally2.8.html 

https://mp.weixin.qq.com/s/IR96o6bgNH0Yzd88AwdLUQ

https://www.tecmint.com/use-pam_tally2-to-lock-and-unlock-ssh-failed-login-attempts/ 

Sunday, February 7, 2021

ntpd服务经常崩溃,开机不自动启动

 报错日志:

ntpd[1706]: 0.0.0.0 0617 07 panic_stop -26754 s; set clock manually within 1000 s.

 

解决方案:

停止chronyd服务

systemctl stop chronyd
systemctl disable chronyd

 

 或者直接改用chronyd

 

参考:

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-configuring_ntp_using_ntpd#s1-Disabling_chrony 

 

 



ACL的permit和deny两种含义

 permit 允许    deny 拒绝  permit 匹配    deny 不匹配