Categories
Apache linux

openssl create cert

Openssl is a handy utility to create self-signed certificates. You can use OpenSSL on all the operating systems such as Windows, MAC, and Linux flavors.

openssl req -new > cert.csr  openssl rsa -in privkey.pem -out key.pem  openssl x509 -in cert.csr -out cert.pem -req -signkey key.pem -days 1001  echo key.pem>>cert.pem
'Coz sharing is caring
Categories
Apache HTTP Concepts Internet linux Microsoft

How to sync server time with Network Time Protocol server

Sync server time on Linux with NTP

What is NTP?

An Internet protocol is used to synchronise clocks of computers, for instance linux server. This protocol is known as NTP (Network Time Protocol).

Following steps shows how to sync time using the terminal. Before we start login to the server via terminal and follow the steps given below.

Step 1: Check whether NTP is installed

Use the ntpstat command to view the status of the NTP service on the instance. It may happen that you get an error message prompting that NTP is not installed. In that case you have to install it on the server.

# sudo ntpstat
-bash: ntpstat: command not found

Step 2: Install NTP

Use the following command to install NTP on server.

# sudo yum install ntp

Step 3: Start NTP

After the installation is complete we need to start NTP by using the following command.

# sudo systemctl start ntpd

Note!

Enable NTP to start at boot:

# sudo systemctl enable ntpd

Stop NTP:

# sudo systemctl stop ntpd

Restart NTP:

# sudo systemctl restart ntpd

Step 4: Sync Time

For this use the following command.

# sudo ntpdate -q 0.rhel.pool.ntp.org

And restart NTP

# sudo systemctl restart ntpd

…and the server time will be synced.

Sync server time on Windows with SNTP

What is SNTP?

Simple Network Time Protocol (SNTP) is a simplified version of Network Time Protocol (NTP).  This is used to synchronize computer clocks on a network. As name defines simplified version of NTP is generally used when full implementation of NTP is not needed.

SNTP is a simplified access strategy for servers and clients using NTP. This simplified protocol is widely used to synchronizes a computer’s system time with a server that has already been synchronized by a source such as a radio, satellite receiver or modem. 

Interestingly, SNTP supports unicast, multicast and anycast operating modes. In unicast mode, the client sends a request to a dedicated server by referencing its unicast address. Once a reply is received from the server, the client determines the time, roundtrip delay and local clock offset in reference to the server. In multicast mode, the server sends an unsolicited message to a dedicated IPv4 or IPv6 local broadcast address. Generally, a multicast client does not send any requests to the service because of the service disruption caused by unknown and untrusted multicast servers. The disruption can be avoided through an access control mechanism that allows a client to select a designated server he or she knows and trusts.

Use below code to sync server time on windows machine

@echo on & @setlocal enableextensions

@echo =========================
@echo Turn off the time service
net stop w32time

@echo =========================
@echo Set the SNTP (Simple Network Time Protocol) source for the time server

w32tm /config /syncfromflags:manual /manualpeerlist:"0.it.pool.ntp.org 1.it.pool.ntp.org 2.it.pool.ntp.org 3.it.pool.ntp.org"

@echo =========================
@echo ... and then turn on the time service back on

net start w32time

@echo =========================
@echo Tell the time sync service to use the changes

w32tm /config /update

@echo =========================
@echo Reset the local computer's time against the time server

w32tm /resync /rediscover

@endlocal & @goto :EOF
'Coz sharing is caring