Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Test environment modifies Linux and Windows server time scheme

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

In the test environment, due to the need to test the activities of different time periods, it is often necessary to modify the time of the server and database. In order to reduce the workload of operation and maintenance, you only need to modify the time of all test servers in one place. Our company mainly uses C#+MySQL, so it involves Windows and Linux. Let's share a synchronization time scheme:

1.Windows time modification

For example, the name of your site is time.abc.com and the name of the application pool is also time.abc.com.

Open group policy and increase server permissions

Just add iis apppool\ time.abc.com users.

2.Linux time modification

We adjust the server time through web. Web is also written in c #, which mainly calls batch processing and then passes in parameters.

Batch files:

@ echo offdate% 1time% 2echo sudo / bin/date-s "% 1% 2" > E:\ tmp\ set.logE:\ scripts\ putty.exe-pw password-m E:\ tmp\ set.log time@192.168.1.100exit

The first parameter is the year / month / day such as: 2017-05-18

The second parameter is time: minutes: seconds, such as 10:04:00

Explain the usage of the putty command line below:

-pw login password

-m executes the contents of the local file, not the Linux remote file

We create the time user on Linux, but the time user has the permission to modify the time

Useradd time

Echo "password" | passwd time-- stdin

Visudo

# comment Defaults requiretty

# Defaults requiretty

# add the following statement

Time ALL = (root) NOPASSWD: / bin/date

It is configured on Linux.

The next step is troublesome:

Now execute the script locally, passing in the parameters:

Time.bat 2017-05-18 10:04:00

Then the screen that putty asks for confirmation will pop up.

At this point, you go to the registry and export the putty configuration file.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\ Software\ SimonTatham\ PuTTY\ SshHostKeys]

"rsa2@22:192.168.1.100"="0x10001,0xd7ffdc7a88b37ed31bac6ebe5ba48d06e30e143fee6746fcee75af577d6b16968c11cbddccd1038a8d330093227eee28a643357537c8bcc5fb8298832a01b0de7a34f3aed85f10a72be183d58b2dcc8cc9933af76ad411bb7701221bd9276285b9116afd3b24ee4d7fec4847366e2a8c01875e6726626e376dfdfeb0a37239d6c22cf5da06f71059a361dbed7ff8539a3d48e18bf822a34d3757cff457c73983b7b14ba336789c6eb3ab418ad2ae574990d10146446a13003b62a74587557b6a778a9af585e5f0fcc32d7af2dfb3e8141b9181d4b043c322e83a26e1593b9fe085f1af227a3c78e4e43ebbc4f6474312ecda286043c5af306a43825050cddb9d"

Something like this.

Modify the registry file exported by the configuration

Replace HKEY_CURRENT_USER with HKEY_USERS\ .default

Windows Registry Editor Version 5.00

[HKEY_USERS\ .default\ Software\ SimonTatham\ PuTTY\ SshHostKeys]

"rsa2@22:192.168.1.100"="0x10001,0xd7ffdc7a88b37ed31bac6ebe5ba48d06e30e143fee6746fcee75af577d6b16968c11cbddccd1038a8d330093227eee28a643357537c8bcc5fb8298832a01b0de7a34f3aed85f10a72be183d58b2dcc8cc9933af76ad411bb7701221bd9276285b9116afd3b24ee4d7fec4847366e2a8c01875e6726626e376dfdfeb0a37239d6c22cf5da06f71059a361dbed7ff8539a3d48e18bf822a34d3757cff457c73983b7b14ba336789c6eb3ab418ad2ae574990d10146446a13003b62a74587557b6a778a9af585e5f0fcc32d7af2dfb3e8141b9181d4b043c322e83a26e1593b9fe085f1af227a3c78e4e43ebbc4f6474312ecda286043c5af306a43825050cddb9d"

And then pour it into the registry.

This is the key that the user can trust with linux, so that all users can trust it, so that they can log in to all Linux servers.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report