CentOS 7 – Some Additional Tricks and Tools

How to install Docker CE on CentOS 8

For daily Linux usage, most system administrators/users must master a few techniques to help them use their Linux machine to its full potential. It is like having a Swiss Army knife and using it to just cut vegetables. Linux hides many useful techniques for daily-life tasks, and CentOS 7 is one of the latest and most reliable OS that many users can use to solve tons of problems.

Through this chapter, we are going to show some of the most needed tools that we believe any system administrator should know how to use. We will be showing how to use these tricks and tools to better manage a CentOS 7 server infrastructure.

Within this chapter, we are going to present the following topics:

  • Connecting to multiple Linux machines using SSH
  • Securing SSH and root login configurations
  • SSH key-based authentication
  • Installation and configuration of SpamAssassin
  • Setting up the Clamav antivirus
  • Configuration of Mytop for a MySQL database
  • Setting up Samba and NFS for file sharing
  • Introduction to some Linux system and network monitoring tools

SSH for remote connection

As we all know, SSH is the Secure Shell connection that we use to connect remotely to a Linux machine. It is the main tool used by system administrators for remote management of their infrastructure. It is one of the essential tools that we find in a basic installation of CentOS 7 and almost all Linux distributions by default.

Usually, SSH is only installed as a client, so you can only remotely connect to other machines; but this is not the case for a basic system installation. When installing the CentOS 7 server, it should already have the SSH server installed and running.

To install the SSH server, we can just rely on the default package repository without adding any extra third-party repository:


$ sudo yum install openssh-server

After having the SSH server installed, we should start the service and enable it for default system startup services:


$ sudo systemctl start sshd.service
$ sudo systemctl enable sshd.service

For security, most machines have the default SSH port closed, so we need to open it from the default firewall manager:


$ sudo firewall­cmd ­­permanent ­­zone=public ­­add­port=ssh/tcp
$ sudo firewall­cmd ­­reload

That’s all we need to do to make a machine remotely accessible.

To access this machine, we only need to type ssh followed by the username and the IP address or the hostname (if the machine is stored at the DNS server or listed at the local /etc/hosts file) of the machine desired to connect to:


$ ssh user1@server1.packt.co.uk
$ ssh user1@10.0.0.10

Usually, if the server is running and the sshd service is listening, then there should be an exchange of public keys upon the first ever connection to that server using this machine. Otherwise, the server will just ask for the desired user password to allow the login.

When we connect to a remote machine using SSH, it is like us having an open window to that machine, and we are kind of stuck to that, which is a network-consuming way of connecting if we are using it for a long period, and especially if we are just connected without really typing any commands. So we need to close the terminal window to leave the remote connection session and free the resources reserved. SSH offers some useful options such as –t. Through this option, we can send a command to be executed on the remote machine and send back the output:


$ ssh -t user1@server1.packt.co.uk cat /etc/hosts

This command will only show the containment of the /etc/hosts file without keeping the windows open.

We can also use SSH to send files between two machines to or from a remote machine, using the scp command:


$ scp user1@server1.packt.co.uk:/home/user1/Desktop/file1.txt  ./Desktop/

In the next section, we will show you how to secure SSH and manage a root login.

Source: https://www.allegrosoft.com/

Comments are closed.