++

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

跳转到目录 点这里  

用ntpdate方式配置

    1)在windows 7上安装 ntp服务提供给VMware上linux系统使用。

          下载  https://www.meinbergglobal.com/download/ntp/windows/ntp-4.2.8p7-win32-setup.exe

           安装

                   安装时选择新建用户,会卡住,然后卸载。

                         安装脚本会自动建一个 名为 ntp的用户。

                   进入win7用户管理,斌与管理员权限,并清除登陆脚本选项乱码。

                   再次运行 ntp-4.2.8p7-win32-setup.exe ,这次选择己存在用户 ntp

                   顺利安装

           然后配置  C:\Program Files (x86)\NTP\etc\ntp.conf 

#默认拒绝所有来源的任何访问
restrict default noquery nopeer nomodify notrap  
restrict -6 default noquery nopeer nomodify notrap  
 
# allow status queries and everything else from localhost 
# 允许本地访问
restrict 127.0.0.1 
restrict -6 ::1 
 
# if you need to allow access from a remote host, you can add lines like this: 
# restrict <IP OF REMOTE HOST> 
# 设置自己需要访问的网段地址
# 设置内网所在的IP段
restrict xxx.xx.xxx.0 mask 255.255.255.0 nomodify
# 设置内网的关网IP
restrict xxx.xxx.xxx.1 mask 255.255.255.0 nomodify
 
# Use drift file 
driftfile "C:\Program Files (x86)\NTP\etc\ntp.drift"
 
# your local system clock, could be used as a backup
# (this is only useful if you need to distribute time no matter how good or bad it is)
# 按自己需求增加上层NTP服务器
server 0.centos.pool.ntp.org prefer 
 
# but it should operate at a high stratum level to let the clients know and force them to
# use any other timesource they may have.
fudge 127.127.1.0 stratum 10
 
# End of generated ntp.conf --- Please edit this to suite your needs

 nat方式上网 ,物理机(win7)通过 vmnet8与虚拟路由器通信。

 网关IP 即为 Virtual Network Editor -> NAT setting-> Gateway IP

  C:\Program Files (x86)\NTP\etc\ntp.conf  必须 同时加上网关IP  和 网关所在网段IP。

  这两条必须同时加上 虚拟机linux上才能找到宿主机(win7)提供的服务。

restrict xxx.xxx.xxx.0 mask 255.255.255.0 nomodify (网段IP)
restrict xxx.xxx.xxx.1 mask 255.255.255.0 nomodify  (网关IP)

修改配置后重启 windows搜索程序 ntp

2)linux上的 npt客户端安装
centos7 yum -y install ntp ntpdate (也可以只装nptdate)
manjaro sudo pacman -S ntp (自动会装上两个)

3)linux上的时间配置
     xxx.xxx.xxx.xxx 为 windows 上 VMnet8 的IP
     ntpdate -d NTP xxx.xxx.xxx.xxx #测试
     ntpdate  xxx.xxx.xxx.xxx  #
     ntpdate  -u xxx.xxx.xxx.xxx #  -u 透过自己防火墙 
     修改 /etc/ntp.conf 把 中 server 改 为 vmnet8 的ip xxx.xxx.xxx.xxx ,只有客户端这个好像不用配

   4)时区问题 

       1)查看上海时区文件是否存在 ls -l /usr/share/zoneinfo/Asia/Shanghai

        2)查看当前时区 ls -l /etc/localtime

  3 ) 把当前时区设为上海时区 ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 

5)把更新时间加入定时任务
centos7
安装crontab:

yum install crontabs

服务操作说明:

/sbin/service crond start //启动服务

/sbin/service crond stop //关闭服务

/sbin/service crond restart //重启服务

/sbin/service crond reload //重新载入配置
cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed
  *  *  *  *  * root /bin/sh /etc/cron.d/ntpdate.sh

cat /etc/cron.d/ntpdate.sh
ntpdate -u xxx.xxx.xxx.xxx

ArchLinux
Manjaro

pacman -S cronie
sudo systemctl enable cronie.service; sudo systemctl start cronie.service
cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed
  *  *  *  *  * root /bin/sh /etc/cron.d/ntpdate.sh

cat /etc/cron.d/ntpdate.sh
ntpdate -u xxx.xxx.xxx.xxx

crontab /etc/crontab

sudo systemctl stop cronie.service
sudo systemctl start cronie.service

crontab -l #列出任务列表

附录一个Manjaro ssh 登陆问题 新版 openssh用 SecureCRT 8.0.4登陆时报错。



 

 

 vim /etc/ssh/ssh_config  加上

KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1

然后

 systemctl stop sshd.service
 systemctl start sshd.service 

posted on 2020-12-01 20:36  自制力缺失症患者  阅读(144)  评论(0)    收藏  举报