What is centos?
CentOS 7 is a (Community Enterprise Operating System). It’s released on May 2004. It’s totally free operating system distribution for the Linux Kernel.
When you want to create a new server, you have to work a few steps, which are part of the basic setup. If you can finish each step successfully, it will work to increase the security, usability of your surveillance and as a solid foundation for your next job.
Step One -Root Login
Actually, the “root” user is the administrator of Linux Environment. And a root user keeps the server’s all control properly.
How to login your server using root? First, you need to your server’s public IP address and the password for the “root” user account.
If you are not connected with your server, please continue, and login as “root” user using the command below.
ssh root@(type your server ip address)
Please acknowledge the host authentication and complete the login process, when it appears, provide your root authentication password.
Step Two – Create a New User
Suppose you are logged in with the root, now you want to create a user named Example. Please see the following command to completely creating a user.
adduser (type your user name)
Now select a password for the new user. To select a new password, enter your new username correctly with the following command.
passwd (type your user name and press enter button)
Type a strong password, and retype it again to verify your new user.
Step Three – Root Privileges
Now, there is a new user account with our regular account facility. However, we will sometimes have to do administrative work.
To avoid logging out our normal user and logging in as root account, we can set up which is known as a "super user" or root facility for our general account. This will allow our common user to run commands with the administrative command over the “sudo” by typing the word before each command.
If you want to add this new benefits with your new user, you will need to add your new user to the "wheel" group. By default, users in CentOS 7 belong to the "wheel" group, so this operating system is allowed to use the "sudo" command.
If you want to add your new user from "root" to the "wheel" group, follow the command below.
gpasswd -a (your user name) wheel
Now your new user can use commands with super user privileges.
Step Four – Configure Your SSH Daemon
Now we can make our server secure by changing our new account's SSH daemon configuration (which we can log in to remotely), which will not allow any remote access to the root account.
Now open the configuration file with text editor from your root user.
To stop remote login, find the following line.
To find the line more easily, please type /PermitRoot and press enter button.
When you find this line properly, now replace “yes” by pressing “cw” then typing “no” and press enter button. When you complete the editing then press the “Escape” button. After saving the file you will see the following line.
Now type :x then press the "Enter" button to save this file and exit.
Step Five – Reload SSH
Now you have changed your configuration, so should be restart SSH so that it uses your new configuration.
To restart SSH type the following command.
systemctl reload sshd
Before logging out of the server, we must check that our new configuration is OK. As long as we can’t confirm that our new connection has been successfully established, we can’t terminate our running connection.
So, open a new window from your server, then login as the new user. You have created a new server configuration, use the following command to verify it.
After you connect your SSH from your new user, then try to test any command with “sudo”.
if all are ok, then you can exit this session by typing,