Centos 7 : Configure NTP Server

0
847

The Network Time Protocol (NTP) is used to synchronize the time of a computer client or server to another server. To install ntp on centos 7 using commands below:

[root@thehackertips ~]# yum -y install ntp

To configure ntp server you needs to open configuration file /etc/ntp.conf.

# Hosts on local network are less restricted.
restrict 172.16.171.0 mask 255.255.255.0 nomodify notrap

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).

# add your ntp server here
server 0.az.pool.ntp.org

#broadcast 192.168.1.255 autokey # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 autokey # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 autokey # manycast client

If you have firewall enabled You may add ntp to firewall allow list and restart the firewall service.

[root@thehackertips ~]# firewall-cmd --add-service=ntp --permanent
[root@thehackertips ~]# firewall-cmd --reload

You can test ntp service ntpq -p commands.

To start, stop, restart and to look at ntp service status You can run commands as follow:

[root@thehackertips ~]# systemctl status ntpd
ntpd.service - Network Time Service
Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled)
Active: active (running) since Mon 2019-10-21 07:01:13 EDT; 1 day 1h ago
Process: 592 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status =0/SUCCESS)
Main PID: 603 (ntpd)
CGroup: /system.slice/ntpd.service
ââ603 /usr/sbin/ntpd -u ntp:ntp -g
ââ604 /usr/sbin/ntpd -u ntp:ntp -g

[root@thehackertips ~]# systemctl stop ntpd
[root@thehackertips ~]# systemctl start ntpd
[root@thehackertips ~]# systemctl restart ntpd

Configure SSH Server

SSH is installed on Centos 7 by default, however it is need to be configured for security reason. IF it is not installed any reason You can install that with this commands:

[root@thehackertips ~]# yum -y install openssh-server openssh-clients
[root@thehackertips ~]# service sshd start

To make some configuration on SSH you need to edit configuration file: /etc/ssh/sshd_config .

There are some main configuration on SSH which you need to follow: disable SSH access for root user, change ssh default port and allow ssh access only for required users. To do that you need to open configuration file and add those lines as below:

[root@thehackertips ~]# vi /etc/ssh/sshd_config
# Add or configure these lines
Port 1234 # for example 1234
PermitRootLogin no # change Yes to No
AllowUsers user1, user2 # user1 and user2 are the ssh allowed users

To connect to another SSH server you need to type ssh and IP address of the remote host:

[root@thehackertips ~]# ssh 172.16.171.201
The authenticity of host '172.16.171.201 (172.16.171.201)' can't be established.
ECDSA key fingerprint is ee:3e:9b:e2:9f:3c:b9:cb:33:c6:70:6f:95:c5:9d:ce.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.171.201' (ECDSA) to the list of known hosts.
root@172.16.171.201's password:

On windows client you can use Putty to connect to Centos 7 with SSH:

LEAVE A REPLY

Please enter your comment!
Please enter your name here