我试图为我的内部networking上的主机设置一个NTP时间服务器来同步。
我需要使用授权才能符合PCI标准。
我使用ntp-keygen -M创build了一组密钥,并将下面的代码片段添加到服务器上的/etc/ntp.conf文件中。
enable auth keys /etc/ntp.keys trustedkey 1 7 17
我无法从客户端连接到服务器。 当我在客户端运行“ntpq -c as”时,我可以看到auth对我的服务器“不好”。 我已经将服务器上生成的密钥文件复制到客户端,并将可信的密钥行添加到客户端,如下所示:
server timeserver key 17 restrict -4 default kod notrap nomodify nopeer noquery restrict -6 default kod notrap nomodify nopeer noquery restrict 127.0.0.1 restrict ::1 keys /etc/ntp.keys trustedkey 1 7 17
看看服务器日志,我可以看到,当我尝试读取文件时,我得到了一个权限被拒绝的错误,如下所示。
Jan 30 12:38:01 ip-10-0-1-103 systemd[1]: Starting LSB: Start NTP daemon... Jan 30 12:38:01 ip-10-0-1-103 ntp[28084]: * Starting NTP server ntpd Jan 30 12:38:01 ip-10-0-1-103 ntpd[28094]: ntpd [email protected] Wed Oct 5 12:34:45 UTC 2016 (1): Starting Jan 30 12:38:01 ip-10-0-1-103 ntpd[28094]: Command line: /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 112:116 Jan 30 12:38:01 ip-10-0-1-103 ntp[28084]: ...done. Jan 30 12:38:01 ip-10-0-1-103 systemd[1]: Started LSB: Start NTP daemon. Jan 30 12:38:01 ip-10-0-1-103 ntpd[28096]: proto: precision = 0.182 usec (-22) Jan 30 12:38:01 ip-10-0-1-103 ntpd[28096]: authreadkeys: file /etc/ntp.keys: Permission denied
我使用客户端机器上的ntpdate来设置服务器的date,所以我非常有信心联网已经启动并正在运行。 我实际上已经禁用了两台服务器上的iptables,而我正忙着设置它。
服务器上的密钥文件是600,如下所示:
-rw------- 1 root root 1066 Jan 30 12:29 ntpkey_MD5key_timeserver.3694768152 lrwxrwxrwx 1 root root 35 Jan 30 12:33 ntp.keys -> ntpkey_MD5key_timeserver.3694768152
我试着改变configuration指向实际的文件,而不是符号链接。
任何人都可以帮我弄清楚系统日志中的错误是什么意思,以及如何解决这个问题?
编辑:看看源代码,它看起来像“权限被拒绝”部分的错误来自操作系统。
我创build了一个Ubuntu 14.04实例,并注意到在相同的“权限被拒绝”消息后,日志中的应用程序装甲消息。
禁用apparmor的ntpconfiguration文件解决了这个问题。