In a test environment, it is often necessary to modify the server and database time due to the need to test the activities of different time periods, in order to reduce the operational workload, you only need to modify the time in one place to modify the time of all test servers. Our company mainly uses c#+mysql, so it involves Windows and Linux. Then share a synchronization time scheme:
1.Windows Time Modification
For example, your site name is time.abc.com application pool name is also time.abc.com
Open Group Policy, increase server permissions
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/96/19/wKioL1kdBN3hJFWTAAI3D729acc796.jpg "title=" 12. JPG "alt=" wkiol1kdbn3hjfwtaai3d729acc796.jpg "/> Add IIS apppool\time.abc.com user can
2.Linux Time Modification
We use the Web to adjust server time, the Web is also written in C #, C # is mainly called batch processing, and then passed parameters can be
Batch file:
@echo offdate%1time%2echo sudo/bin/date-s "%1%2" >E:\TMP\SET.LOGE:\SCRIPTS\PUTTY.EXE-PW password-m E:\tmp\set.lo G [Email Protected]exit
The first parameter is the year/month/day: 2017/05/18
The second parameter is the time: minute: Seconds such as: 10:04:00
Description of the following Putty command line usage:
-PW Login Password
-M is the content of the local file, not the Linux remote file
We create a time user on Linux, while the user has the Modify Times permission
Useradd time
echo "Password" |passwd time--stdin
Visudo
#注释Defaults Requiretty
#Defaults Requiretty
#增加如下语句
Time All = (root) nopasswd:/bin/date
It's configured on Linux.
The next step is more troublesome:
Now execute the script locally, passing in the parameters:
Time.bat 2017/05/18 10:04:00
Then it pops up the Putty request Confirmation screen.
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/96/19/wKiom1kdAu-zOn4EAACig2a6URQ823.jpg "title=" 222. JPG "alt=" wkiom1kdau-zon4eaacig2a6urq823.jpg "/>
At this point, you go to the registry. Export the Putty configuration file
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\software\simontatham\putty\sshhostkeys]
"[Email protected]:192.168.1.100" = "0x10001, 0xd7ffdc7a88b37ed31bac6ebe5ba48d06e30e143fee6746fcee75af577d6b16968c11cbddccd1038a8d330093227eee28a643357537c8bcc5fb82988 32a01b0de7a34f3aed85f10a72be183d58b2dcc8cc9933af76ad411bb7701221bd9276285b9116afd3b24ee4d7fec4847366e2a8c01875e6726626e37 6dfdfeb0a37239d6c22cf5da06f71059a361dbed7ff8539a3d48e18bf822a34d3757cff457c73983b7b14ba336789c6eb3ab418ad2ae574990d101464 46a13003b62a74587557b6a778a9af585e5f0fcc32d7af2dfb3e8141b9181d4b043c322e83a26e1593b9fe085f1af227a3c78e4e43ebbc4f6474312ec da286043c5af306a43825050cddb9d "
Similar to this
To modify the configuration Export Registry file
Replace the HKEY_CURRENT_USER with the hkey_users\. DEFAULT
Windows Registry Editor Version 5.00
[hkey_users\. DEFAULT\software\simontatham\putty\sshhostkeys]
"[Email protected]:192.168.1.100" = "0x10001, 0xd7ffdc7a88b37ed31bac6ebe5ba48d06e30e143fee6746fcee75af577d6b16968c11cbddccd1038a8d330093227eee28a643357537c8bcc5fb82988 32a01b0de7a34f3aed85f10a72be183d58b2dcc8cc9933af76ad411bb7701221bd9276285b9116afd3b24ee4d7fec4847366e2a8c01875e6726626e37 6dfdfeb0a37239d6c22cf5da06f71059a361dbed7ff8539a3d48e18bf822a34d3757cff457c73983b7b14ba336789c6eb3ab418ad2ae574990d101464 46a13003b62a74587557b6a778a9af585e5f0fcc32d7af2dfb3e8141b9181d4b043c322e83a26e1593b9fe085f1af227a3c78e4e43ebbc4f6474312ec da286043c5af306a43825050cddb9d "
And then pour it into the registry.
This is the key that the user and Linux trust, so that all users can trust, so as to log on all the Linux server
This article is from "Maple Night" blog, please be sure to keep this source http://fengwan.blog.51cto.com/508652/1926911
Test environment modifies Linux and Windows Server time scenarios